From 2dbc39f699c2da332b9985036a7f0b70b005c3a9 Mon Sep 17 00:00:00 2001 From: therealmarv <1050582+therealmarv@users.noreply.github.com> Date: Mon, 18 Nov 2024 23:33:02 +0200 Subject: [PATCH] simplify logger --- src/lib/logger.ts | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/lib/logger.ts b/src/lib/logger.ts index 1f07b68..4f99709 100644 --- a/src/lib/logger.ts +++ b/src/lib/logger.ts @@ -3,14 +3,8 @@ import debug from 'debug' const logger = { debug: debug('app:debug'), info: debug('app:info'), - warn: (...args: unknown[]) => { - debug('app:warn')(...args) - console.warn('[WARN]', ...args) - }, - error: (...args: unknown[]) => { - debug('app:error')(...args) - console.error('[ERROR]', ...args) - }, + warn: debug('app:warn'), + error: debug('app:error'), } // Enable debug output in development @@ -18,4 +12,8 @@ if (process.env.NODE_ENV === 'development') { debug.enable('app:*') } +// Forward warnings and errors to console +logger.warn.log = console.warn.bind(console) +logger.error.log = console.error.bind(console) + export default logger