From 895fae9cf580aa628e564616db413ae25e03411e Mon Sep 17 00:00:00 2001 From: Joao Moreno Date: Tue, 5 Dec 2017 15:48:41 +0100 Subject: [PATCH] check log level before sending log to spdlog fixes #39641 --- src/vs/platform/log/node/spdlogService.ts | 30 ++++++++++++++++------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/src/vs/platform/log/node/spdlogService.ts b/src/vs/platform/log/node/spdlogService.ts index d554b355a359..fa6952da2a12 100644 --- a/src/vs/platform/log/node/spdlogService.ts +++ b/src/vs/platform/log/node/spdlogService.ts @@ -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 {