From 77c7c8d6ed1eb6de5471af1dad0f34f65d39d91b Mon Sep 17 00:00:00 2001 From: Fedor Indutny <79877362+indutny-signal@users.noreply.github.com> Date: Mon, 16 Jun 2025 14:36:59 -0700 Subject: [PATCH] Fix creation of pino children --- ts/logging/log.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/ts/logging/log.ts b/ts/logging/log.ts index 742b52192f6..d10fbfac172 100644 --- a/ts/logging/log.ts +++ b/ts/logging/log.ts @@ -132,11 +132,11 @@ export const log: LoggerType = { info: pinoInstance.info.bind(pinoInstance), debug: pinoInstance.debug.bind(pinoInstance), trace: pinoInstance.trace.bind(pinoInstance), - child: createLogger.bind(pinoInstance), + child: child.bind(pinoInstance), }; -export function createLogger(name: string): LoggerType { - const instance = pinoInstance.child({}, { msgPrefix: `[${name}] ` }); +function child(this: typeof pinoInstance, name: string): LoggerType { + const instance = this.child({}, { msgPrefix: `[${name}] ` }); return { fatal: instance.fatal.bind(instance), @@ -145,10 +145,12 @@ export function createLogger(name: string): LoggerType { info: instance.info.bind(instance), debug: instance.debug.bind(instance), trace: instance.trace.bind(instance), - child: createLogger.bind(instance), + child: child.bind(instance), }; } +export const createLogger = log.child; + /** * Sets the low-level logging interface. Should be called early in a process's * life.