check log level before sending log to spdlog

fixes #39641
This commit is contained in:
Joao Moreno
2017-12-05 15:48:47 +01:00
parent a93288cac0
commit 895fae9cf5
+21 -9
View File
@@ -18,6 +18,7 @@ export class SpdLogService implements ILogService {
_serviceBrand: any;
private level: LogLevel = LogLevel.Error;
private logger: RotatingLogger;
private disposables: IDisposable[] = [];
@@ -49,33 +50,44 @@ export class SpdLogService implements ILogService {
}
setLevel(logLevel: LogLevel): void {
this.logger.setLevel(logLevel);
this.level = logLevel;
}
// TODO, what about ARGS?
trace(message: string, ...args: any[]): void {
this.logger.trace(this.format(message, args));
if (this.level <= LogLevel.Trace) {
this.logger.trace(this.format(message, args));
}
}
debug(message: string, ...args: any[]): void {
this.logger.debug(this.format(message, args));
if (this.level <= LogLevel.Debug) {
this.logger.debug(this.format(message, args));
}
}
info(message: string, ...args: any[]): void {
this.logger.info(this.format(message, args));
if (this.level <= LogLevel.Info) {
this.logger.info(this.format(message, args));
}
}
warn(message: string, ...args: any[]): void {
this.logger.warn(this.format(message, args));
if (this.level <= LogLevel.Warning) {
this.logger.warn(this.format(message, args));
}
}
error(arg: string | Error, ...args: any[]): void {
const message = arg instanceof Error ? arg.stack : arg;
this.logger.error(this.format(message, args));
if (this.level <= LogLevel.Error) {
const message = arg instanceof Error ? arg.stack : arg;
this.logger.error(this.format(message, args));
}
}
critical(message: string, ...args: any[]): void {
this.logger.critical(this.format(message, args));
if (this.level <= LogLevel.Critical) {
this.logger.critical(this.format(message, args));
}
}
dispose(): void {