From de3f7728be907ec229861d46ce5f903e50d745d0 Mon Sep 17 00:00:00 2001 From: Jacob Phillips Date: Mon, 18 Nov 2024 14:55:11 -0500 Subject: [PATCH] try to figure out why log levels are ignored on gh-pages --- src/lib/index.ts | 1 + src/lib/log.ts | 27 ++++++++++++++++++++------- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/src/lib/index.ts b/src/lib/index.ts index 4fc8ebb..10541c5 100644 --- a/src/lib/index.ts +++ b/src/lib/index.ts @@ -20,6 +20,7 @@ import { TelemetryServiceMock } from './telemetry/service_mock'; const init_start = performance.now(); export const log = new Log(IS_PRODUCTION_BUILD ? Log.INFO : Log.TRACE); +log.setLevel(IS_PRODUCTION_BUILD ? Log.INFO : Log.TRACE); log.debug(init_start, 'Initializing...'); log.debug('Config:', { diff --git a/src/lib/log.ts b/src/lib/log.ts index 7763442..5c468b2 100644 --- a/src/lib/log.ts +++ b/src/lib/log.ts @@ -1,10 +1,19 @@ +const LEVEL = { + ASSERT: 1, + ERROR: 2, + WARN: 3, + INFO: 4, + DEBUG: 5, + TRACE: 6 +} as const; + export class Log { - static readonly ASSERT = 1; - static readonly ERROR = 2; - static readonly WARN = 3; - static readonly INFO = 4; - static readonly DEBUG = 5; - static readonly TRACE = 6; + static readonly ASSERT = LEVEL.ASSERT; + static readonly ERROR = LEVEL.ERROR; + static readonly WARN = LEVEL.WARN; + static readonly INFO = LEVEL.INFO; + static readonly DEBUG = LEVEL.DEBUG; + static readonly TRACE = LEVEL.TRACE; assert = console.assert.bind(console); error = console.error.bind(console); @@ -13,7 +22,7 @@ export class Log { debug = console.debug.bind(console); trace = console.log.bind(console); - level = Log.INFO; + level: number = Log.INFO; constructor(level?: number) { if (level !== undefined) { @@ -23,6 +32,10 @@ export class Log { } setLevel(level: number) { + console.log('Current log level:', this.level); + console.log('New log level:', level); + console.log('Log.INFO:', Log.INFO); + console.log('Log.DEBUG:', Log.DEBUG); this.level = level; if (level >= Log.ASSERT) this.assert = console.assert.bind(console); else this.assert = () => {};