diff --git a/src/common/services/LogService.ts b/src/common/services/LogService.ts index fb5bfded..b297049e 100644 --- a/src/common/services/LogService.ts +++ b/src/common/services/LogService.ts @@ -33,7 +33,8 @@ const LOG_PREFIX = 'xterm.js: '; export class LogService extends Disposable implements ILogService { public serviceBrand: any; - public logLevel: LogLevelEnum = LogLevelEnum.OFF; + private _logLevel: LogLevelEnum = LogLevelEnum.OFF; + public get logLevel(): LogLevelEnum { return this._logLevel; } constructor( @IOptionsService private readonly _optionsService: IOptionsService @@ -44,7 +45,7 @@ export class LogService extends Disposable implements ILogService { } private _updateLogLevel(): void { - this.logLevel = optionsKeyToLogLevel[this._optionsService.rawOptions.logLevel]; + this._logLevel = optionsKeyToLogLevel[this._optionsService.rawOptions.logLevel]; } private _evalLazyOptionalParams(optionalParams: any[]): void { @@ -61,25 +62,25 @@ export class LogService extends Disposable implements ILogService { } public debug(message: string, ...optionalParams: any[]): void { - if (this.logLevel <= LogLevelEnum.DEBUG) { + if (this._logLevel <= LogLevelEnum.DEBUG) { this._log(this._optionsService.options.logger?.debug.bind(this._optionsService.options.logger) ?? console.log, message, optionalParams); } } public info(message: string, ...optionalParams: any[]): void { - if (this.logLevel <= LogLevelEnum.INFO) { + if (this._logLevel <= LogLevelEnum.INFO) { this._log(this._optionsService.options.logger?.info.bind(this._optionsService.options.logger) ?? console.info, message, optionalParams); } } public warn(message: string, ...optionalParams: any[]): void { - if (this.logLevel <= LogLevelEnum.WARN) { + if (this._logLevel <= LogLevelEnum.WARN) { this._log(this._optionsService.options.logger?.warn.bind(this._optionsService.options.logger) ?? console.warn, message, optionalParams); } } public error(message: string, ...optionalParams: any[]): void { - if (this.logLevel <= LogLevelEnum.ERROR) { + if (this._logLevel <= LogLevelEnum.ERROR) { this._log(this._optionsService.options.logger?.error.bind(this._optionsService.options.logger) ?? console.error, message, optionalParams); } } diff --git a/src/common/services/Services.ts b/src/common/services/Services.ts index 10c2fbb7..b4021e45 100644 --- a/src/common/services/Services.ts +++ b/src/common/services/Services.ts @@ -157,7 +157,7 @@ export const ILogService = createDecorator('LogService'); export interface ILogService { serviceBrand: undefined; - logLevel: LogLevelEnum; + readonly logLevel: LogLevelEnum; debug(message: any, ...optionalParams: any[]): void; info(message: any, ...optionalParams: any[]): void;