Merge from vscode 2f984aad710215f4e4684a035bb02f55d1a9e2cc (#9819)

This commit is contained in:
Anthony Dresser
2020-04-01 00:44:39 -07:00
committed by GitHub
parent 0e27aaa61f
commit 0bfbdc62ed
247 changed files with 5402 additions and 3311 deletions

View File

@@ -7,11 +7,23 @@ import * as vscode from 'vscode';
type LogLevel = 'Trace' | 'Info' | 'Error';
enum Level {
Trace = 'trace',
Info = 'Info'
}
class Log {
private output: vscode.OutputChannel;
private level: Level;
constructor() {
this.output = vscode.window.createOutputChannel('Account');
this.level = vscode.workspace.getConfiguration('microsoftAccount').get('logLevel') || Level.Info;
vscode.workspace.onDidChangeConfiguration(e => {
if (e.affectsConfiguration('microsoftAccount.logLevel')) {
this.level = vscode.workspace.getConfiguration('microsoftAccount').get('logLevel') || Level.Info;
}
});
}
private data2String(data: any): string {
@@ -32,6 +44,12 @@ class Log {
this.logLevel('Error', message, data);
}
public trace(message: string, data?: any): void {
if (this.level === Level.Trace) {
this.logLevel('Trace', message, data);
}
}
public logLevel(level: LogLevel, message: string, data?: any): void {
this.output.appendLine(`[${level} - ${this.now()}] ${message}`);
if (data) {