From 051939d57b0441b573bf08e4b4ee4784c7130cea Mon Sep 17 00:00:00 2001 From: Dirk Holtwick Date: Fri, 15 Mar 2024 15:11:52 +0100 Subject: [PATCH] fix: log.generic unused --- src/browser/log/log-browser-factory.ts | 32 +++++++++++++------------- src/common/log/log-console-capture.ts | 14 +++++------ src/common/log/log-context.ts | 12 ++++------ 3 files changed, 27 insertions(+), 31 deletions(-) diff --git a/src/browser/log/log-browser-factory.ts b/src/browser/log/log-browser-factory.ts index 76bc446..a6dccb1 100644 --- a/src/browser/log/log-browser-factory.ts +++ b/src/browser/log/log-browser-factory.ts @@ -59,22 +59,22 @@ export function LoggerBrowserSetupDebugFactory(opt: LogHandlerOptions = {}) { log.warn = defineForLogLevel(LogLevelWarn, originalConsole.warn.bind(originalConsole.console, ...fixedArgs)) log.error = defineForLogLevel(LogLevelError, originalConsole.error.bind(originalConsole.console, ...fixedArgs)) - /** - * Takes log level as argument, but will fail to show all the debug info - * as the others do like file name and line number of the originating call - */ - log.generic = (logLevel: LogLevel, ...args) => { - if (level <= logLevel) { - if (logLevel === LogLevelError) - originalConsole.error(...fixedArgs, ...args) - else if (logLevel === LogLevelWarn) - originalConsole.warn(...fixedArgs, ...args) - else if (logLevel === LogLevelInfo) - originalConsole.info(...fixedArgs, ...args) - else - originalConsole.debug(...fixedArgs, ...args) - } - } + // /** + // * Takes log level as argument, but will fail to show all the debug info + // * as the others do like file name and line number of the originating call + // */ + // log.generic = (logLevel: LogLevel, ...args) => { + // if (level <= logLevel) { + // if (logLevel === LogLevelError) + // originalConsole.error(...fixedArgs, ...args) + // else if (logLevel === LogLevelWarn) + // originalConsole.warn(...fixedArgs, ...args) + // else if (logLevel === LogLevelInfo) + // originalConsole.info(...fixedArgs, ...args) + // else + // originalConsole.debug(...fixedArgs, ...args) + // } + // } log.fatal = defineForLogLevel(LogLevelFatal, (...args: any) => { log.error(...args) diff --git a/src/common/log/log-console-capture.ts b/src/common/log/log-console-capture.ts index e45ddad..41f3178 100644 --- a/src/common/log/log-console-capture.ts +++ b/src/common/log/log-console-capture.ts @@ -17,17 +17,17 @@ export function logCaptureConsole(log: LoggerInterface) { onlyOnce = true - globalThis.console.log = (...args: any[]) => log.generic(LogLevelDebug, ...args) - globalThis.console.debug = (...args: any[]) => log.generic(LogLevelDebug, ...args) - globalThis.console.warn = (...args: any[]) => log.generic(LogLevelWarn, ...args) - globalThis.console.error = (...args: any[]) => log.generic(LogLevelError, ...args) - globalThis.console.info = (...args: any[]) => log.generic(LogLevelInfo, ...args) + globalThis.console.log = (...args: any[]) => log.debug(LogLevelDebug, ...args) + globalThis.console.debug = (...args: any[]) => log.debug(LogLevelDebug, ...args) + globalThis.console.warn = (...args: any[]) => log.warn(LogLevelWarn, ...args) + globalThis.console.error = (...args: any[]) => log.error(LogLevelError, ...args) + globalThis.console.info = (...args: any[]) => log.info(LogLevelInfo, ...args) globalThis.addEventListener?.('unhandledrejection', (event: any) => { - log.generic(LogLevelError, 'onUnhandledrejection', event) + log.error('onUnhandledrejection', event) }) globalThis.addEventListener?.('error', (event: any) => { - log.generic(LogLevelError, 'onError', event) + log.error('onError', event) }) } diff --git a/src/common/log/log-context.ts b/src/common/log/log-context.ts index b46a53b..c2a7f11 100644 --- a/src/common/log/log-context.ts +++ b/src/common/log/log-context.ts @@ -24,26 +24,22 @@ export function LoggerContext(_prefix = ''): LoggerContextInterface { } const emit = (msg: LogMessage) => { - // if (log.active === true) { - // if (msg.level >= Logger.level && msg.level >= log.level) { if (logCheckNamespace(name)) { for (const handler of logHandlers) { if (handler) handler(msg) } } - // } - // } } const log = defineForLogLevel(LogLevelDebug, (...messages: any[]) => { emit({ name, messages, level: LogLevelDebug }) }) - log.generic = function (level: LogLevel, ...messages: any[]) { - if (logLevel <= level) - emit({ name, messages, level }) - } + // log.generic = function (level: LogLevel, ...messages: any[]) { + // if (logLevel <= level) + // emit({ name, messages, level }) + // } log.label = name // log.active = true