Browse Source

Fixes logging

main
Eric Amodio 6 years ago
parent
commit
1088e3e685
1 changed files with 12 additions and 12 deletions
  1. +12
    -12
      src/logger.ts

+ 12
- 12
src/logger.ts View File

@ -37,26 +37,26 @@ export class Logger {
}
static debug(message?: any, ...params: any[]): void {
if (this.level !== LogLevel.Debug && !Logger.isDebugging) return;
if (Logger.isDebugging) {
console.log(this.timestamp, ConsolePrefix, message, ...params);
console.log(this.timestamp, ConsolePrefix, message || '', ...params);
}
if (this.level !== LogLevel.Debug) return;
if (this.output !== undefined) {
this.output.appendLine(`${this.timestamp} ${message} ${this.toLoggableParams(true, params)}`);
this.output.appendLine(`${this.timestamp} ${message || ''} ${this.toLoggableParams(true, params)}`);
}
}
static error(ex: Error, message?: string, ...params: any[]): void {
if (Logger.isDebugging) {
console.error(this.timestamp, ConsolePrefix, message, ...params, ex);
console.error(this.timestamp, ConsolePrefix, message || '', ...params, ex);
}
if (this.level === LogLevel.Silent) return;
if (this.output !== undefined) {
this.output.appendLine(`${this.timestamp} ${message} ${this.toLoggableParams(false, params)}\n${ex}`);
this.output.appendLine(`${this.timestamp} ${message || ''} ${this.toLoggableParams(false, params)}\n${ex}`);
}
// Telemetry.trackException(ex);
@ -64,37 +64,37 @@ export class Logger {
static log(message?: any, ...params: any[]): void {
if (Logger.isDebugging) {
console.log(this.timestamp, ConsolePrefix, message, ...params);
console.log(this.timestamp, ConsolePrefix, message || '', ...params);
}
if (this.level !== LogLevel.Verbose && this.level !== LogLevel.Debug) return;
if (this.output !== undefined) {
this.output.appendLine(`${this.timestamp} ${message} ${this.toLoggableParams(false, params)}`);
this.output.appendLine(`${this.timestamp} ${message || ''} ${this.toLoggableParams(false, params)}`);
}
}
static logWithDebugParams(message?: any, ...params: any[]): void {
if (Logger.isDebugging) {
console.log(this.timestamp, ConsolePrefix, message, ...params);
console.log(this.timestamp, ConsolePrefix, message || '', ...params);
}
if (this.level !== LogLevel.Verbose && this.level !== LogLevel.Debug) return;
if (this.output !== undefined) {
this.output.appendLine(`${this.timestamp} ${message} ${this.toLoggableParams(true, params)}`);
this.output.appendLine(`${this.timestamp} ${message || ''} ${this.toLoggableParams(true, params)}`);
}
}
static warn(message?: any, ...params: any[]): void {
if (Logger.isDebugging) {
console.warn(this.timestamp, ConsolePrefix, message, ...params);
console.warn(this.timestamp, ConsolePrefix, message || '', ...params);
}
if (this.level === LogLevel.Silent) return;
if (this.output !== undefined) {
this.output.appendLine(`${this.timestamp} ${message} ${this.toLoggableParams(false, params)}`);
this.output.appendLine(`${this.timestamp} ${message || ''} ${this.toLoggableParams(false, params)}`);
}
}

Loading…
Cancel
Save