From 764d25ad9b43c8bce6f78c6573bcf51cdf92897a Mon Sep 17 00:00:00 2001 From: Aras Abbasi Date: Thu, 10 Jul 2025 22:14:11 +0200 Subject: [PATCH] fix: createLogger should not break pino --- src/create-logger.ts | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/create-logger.ts b/src/create-logger.ts index e86d953b..b49ba68c 100644 --- a/src/create-logger.ts +++ b/src/create-logger.ts @@ -5,10 +5,18 @@ export interface Logger { error: (...data: any[]) => void; } -export const createLogger = (logger?: Partial): Logger => ({ - debug: () => {}, - info: () => {}, - warn: console.warn.bind(console), - error: console.error.bind(console), - ...logger, -}); +export const createLogger = (logger = {} as Partial): Logger => { + if (typeof logger.debug !== "function") { + logger.debug = () => {}; + } + if (typeof logger.info !== "function") { + logger.info = () => {}; + } + if (typeof logger.warn !== "function") { + logger.warn = console.warn.bind(console); + } + if (typeof logger.error !== "function") { + logger.error = console.error.bind(console); + } + return logger as Logger; +};