From ad7ebe21d3d90c61f983b0cb90dd8f82a6c5d6a3 Mon Sep 17 00:00:00 2001 From: Shinwoo PARK Date: Thu, 27 Mar 2025 06:12:26 +0900 Subject: [PATCH] feat: make formattedScope colored same as scopeId --- packages/nestlogged/src/logger.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/packages/nestlogged/src/logger.ts b/packages/nestlogged/src/logger.ts index 3436d18..3f597f6 100644 --- a/packages/nestlogged/src/logger.ts +++ b/packages/nestlogged/src/logger.ts @@ -386,7 +386,7 @@ export class ConsoleLogger implements LoggerService { if (!scopeInfo) return ['', '']; const scopeId = scopeInfo[NestloggedScopeId]; const formattedScope = formatScope(scopeInfo[NestloggedScope]); - return this.options.colors ? [`ID=[${clc.cyanBright(scopeId)}] | `, formattedScope] : [`ID=[${scopeId}] | `, formattedScope] + return this.options.colors ? [`ID=[${clc.cyanBright(scopeId)}] | `, clc.cyanBright(formattedScope)] : [`ID=[${scopeId}] | `, formattedScope] } protected printAsJson( @@ -462,9 +462,7 @@ export class ConsoleLogger implements LoggerService { const output = this.stringifyMessage(message, logLevel); pidMessage = this.colorize(pidMessage, logLevel); formattedLogLevel = this.colorize(formattedLogLevel, logLevel); - let colorizedScope = ''; - if (formattedScopeInfo[1]) colorizedScope = this.colorize(formattedScopeInfo[1], logLevel); - return `${pidMessage}${this.getTimestamp()} ${formattedLogLevel} ${contextMessage}${formattedScopeInfo[0]}${colorizedScope}${output}${timestampDiff}\n`; + return `${pidMessage}${this.getTimestamp()} ${formattedLogLevel} ${contextMessage}${formattedScopeInfo[0]}${formattedScopeInfo[1]}${output}${timestampDiff}\n`; } protected stringifyMessage(message: unknown, logLevel: LogLevel) {