diff --git a/src/vs/base/node/storage.ts b/src/vs/base/node/storage.ts index 9ddb2a77f17ca9770a52eea485bf4ad758374386..3c041cba7b9a603f7a4e8a07284e178ebbc76097 100644 --- a/src/vs/base/node/storage.ts +++ b/src/vs/base/node/storage.ts @@ -21,8 +21,6 @@ export interface IStorageOptions { export interface IStorageLoggingOptions { logError?: (error: string | Error) => void; - - trace?: boolean; logTrace?: (msg: string) => void; } @@ -509,27 +507,32 @@ export class SQLiteStorageImpl { } class SQLiteStorageLogger { - private readonly logTrace: boolean; - private readonly logError: boolean; + private readonly logTrace: (msg: string) => void; + private readonly logError: (error: string | Error) => void; + + constructor(options?: IStorageLoggingOptions) { + if (options && typeof options.logTrace === 'function') { + this.logTrace = options.logTrace; + } - constructor(private readonly options?: IStorageLoggingOptions) { - this.logTrace = !!(options && options.trace && typeof options.logTrace === 'function'); - this.logError = !!(options && typeof options.logError === 'function'); + if (options && typeof options.logError === 'function') { + this.logError = options.logError; + } } get isTracing(): boolean { - return this.logTrace; + return !!this.logTrace; } trace(msg: string): void { - if (this.logTrace && this.options && this.options.logTrace) { - this.options.logTrace(msg); + if (this.logTrace) { + this.logTrace(msg); } } error(error: string | Error): void { - if (this.logError && this.options && this.options.logError) { - this.options.logError(error); + if (this.logError) { + this.logError(error); } } } diff --git a/src/vs/platform/storage/node/storageService.ts b/src/vs/platform/storage/node/storageService.ts index 80fc4491c90ad298244d869837e5525325171a0e..076e091c43411a857da73b1547f2264420583064 100644 --- a/src/vs/platform/storage/node/storageService.ts +++ b/src/vs/platform/storage/node/storageService.ts @@ -69,8 +69,7 @@ export class StorageService extends Disposable implements IStorageService { super(); this.loggingOptions = { - trace: logService.getLevel() === LogLevel.Trace, - logTrace: msg => logService.trace(msg), + logTrace: (logService.getLevel() === LogLevel.Trace) ? msg => logService.trace(msg) : void 0, logError: error => { logService.error(error);