From 6ac027b47c91edfce25f981999660c0eb563e75e Mon Sep 17 00:00:00 2001 From: Andrea Amorosi Date: Wed, 2 Aug 2023 17:29:41 +0200 Subject: [PATCH] chore(logger): extracted logger creation into protected method --- packages/logger/src/Logger.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/packages/logger/src/Logger.ts b/packages/logger/src/Logger.ts index 1396c16f91..e9432121cf 100644 --- a/packages/logger/src/Logger.ts +++ b/packages/logger/src/Logger.ts @@ -237,7 +237,7 @@ class Logger extends Utility implements ClassThatLogs { logFormatter: this.getLogFormatter(), }; const parentsPowertoolsLogData = this.getPowertoolLogData(); - const childLogger = new Logger( + const childLogger = this.createLogger( merge(parentsOptions, parentsPowertoolsLogData, options) ); @@ -554,6 +554,16 @@ class Logger extends Utility implements ClassThatLogs { this.processLogItem(16, input, extraInput); } + /** + * Creates a new Logger instance. + * + * @param {ConstructorOptions} [options] + * @returns {Logger} + */ + protected createLogger(options?: ConstructorOptions): Logger { + return new Logger(options); + } + /** * Decides whether the current log item should be printed or not. *