From 39fff87f52a279d713555a3e1dea80736e4b7c98 Mon Sep 17 00:00:00 2001 From: Tilman Vatteroth Date: Fri, 12 May 2023 08:45:27 +0200 Subject: [PATCH] fix: migrate import code Signed-off-by: Tilman Vatteroth --- backend/src/logger/console-logger.service.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/backend/src/logger/console-logger.service.ts b/backend/src/logger/console-logger.service.ts index 88271ac0e..c494ad19f 100644 --- a/backend/src/logger/console-logger.service.ts +++ b/backend/src/logger/console-logger.service.ts @@ -11,12 +11,12 @@ import { Scope, } from '@nestjs/common'; import { isObject } from '@nestjs/common/utils/shared.utils'; +import { blue, cyanBright, green, magentaBright, red, yellow } from 'cli-color'; import appConfiguration, { AppConfig } from '../config/app.config'; import { Loglevel } from '../config/loglevel.enum'; import { needToLog } from '../config/utils'; -import clc = require('cli-color'); import DateTimeFormatOptions = Intl.DateTimeFormatOptions; @Injectable({ scope: Scope.TRANSIENT }) @@ -44,7 +44,7 @@ export class ConsoleLoggerService implements LoggerService { error(message: unknown, trace = '', functionContext?: string): void { this.printMessage( message, - clc.red, + red, this.makeContextString(functionContext), false, ); @@ -55,7 +55,7 @@ export class ConsoleLoggerService implements LoggerService { if (needToLog(this.appConfig.loglevel, Loglevel.INFO)) { this.printMessage( message, - clc.green, + green, this.makeContextString(functionContext), false, ); @@ -66,7 +66,7 @@ export class ConsoleLoggerService implements LoggerService { if (needToLog(this.appConfig.loglevel, Loglevel.WARN)) { this.printMessage( message, - clc.yellow, + yellow, this.makeContextString(functionContext), false, ); @@ -77,7 +77,7 @@ export class ConsoleLoggerService implements LoggerService { if (needToLog(this.appConfig.loglevel, Loglevel.DEBUG)) { this.printMessage( message, - clc.magentaBright, + magentaBright, this.makeContextString(functionContext), false, ); @@ -88,7 +88,7 @@ export class ConsoleLoggerService implements LoggerService { if (needToLog(this.appConfig.loglevel, Loglevel.TRACE)) { this.printMessage( message, - clc.cyanBright, + cyanBright, this.makeContextString(functionContext), false, ); @@ -155,7 +155,7 @@ export class ConsoleLoggerService implements LoggerService { localeStringOptions, ); - const contextMessage = context ? clc.blue(`[${context}] `) : ''; + const contextMessage = context ? blue(`[${context}] `) : ''; const timestampDiff = this.updateAndGetTimestampDiff(isTimeDiffEnabled); process.stdout.write( @@ -166,7 +166,7 @@ export class ConsoleLoggerService implements LoggerService { private updateAndGetTimestampDiff(isTimeDiffEnabled?: boolean): string { const includeTimestamp = this.lastTimestamp && isTimeDiffEnabled; const result = includeTimestamp - ? clc.yellow(` +${Date.now() - this.lastTimestamp}ms`) + ? yellow(` +${Date.now() - this.lastTimestamp}ms`) : ''; this.lastTimestamp = Date.now(); return result;