From 13adf1f1140b54bac4e4fc93083df646182c176f Mon Sep 17 00:00:00 2001 From: Vasyl Ivanchuk Date: Wed, 13 Mar 2024 18:08:27 +0200 Subject: [PATCH] fix: log timestamps in ISO8601 for production --- packages/api/src/logger.ts | 8 +++++--- packages/data-fetcher/src/logger.ts | 8 +++++--- packages/worker/src/logger.ts | 8 +++++--- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/packages/api/src/logger.ts b/packages/api/src/logger.ts index 8a53479c6a..d9c1fc7875 100644 --- a/packages/api/src/logger.ts +++ b/packages/api/src/logger.ts @@ -5,9 +5,11 @@ import { format, transports, Logform } from "winston"; export const getLogger = (environment: string, logLevel: string): LoggerService => { let defaultLogLevel = "debug"; const loggerFormatters: Logform.Format[] = [ - format.timestamp({ - format: "DD/MM/YYYY HH:mm:ss.SSS", - }), + environment === "production" + ? format.timestamp() + : format.timestamp({ + format: "DD/MM/YYYY HH:mm:ss.SSS", + }), format.ms(), utilities.format.nestLike("API", {}), ]; diff --git a/packages/data-fetcher/src/logger.ts b/packages/data-fetcher/src/logger.ts index 76f0e87c08..29d66a8d32 100644 --- a/packages/data-fetcher/src/logger.ts +++ b/packages/data-fetcher/src/logger.ts @@ -5,9 +5,11 @@ const { NODE_ENV, LOG_LEVEL } = process.env; let defaultLogLevel = "debug"; const loggerFormatters: Logform.Format[] = [ - format.timestamp({ - format: "DD/MM/YYYY HH:mm:ss.SSS", - }), + NODE_ENV === "production" + ? format.timestamp() + : format.timestamp({ + format: "DD/MM/YYYY HH:mm:ss.SSS", + }), format.ms(), utilities.format.nestLike("DataFetcher", {}), ]; diff --git a/packages/worker/src/logger.ts b/packages/worker/src/logger.ts index 48476324d8..ff731998bc 100644 --- a/packages/worker/src/logger.ts +++ b/packages/worker/src/logger.ts @@ -5,9 +5,11 @@ const { NODE_ENV, LOG_LEVEL } = process.env; let defaultLogLevel = "debug"; const loggerFormatters: Logform.Format[] = [ - format.timestamp({ - format: "DD/MM/YYYY HH:mm:ss.SSS", - }), + NODE_ENV === "production" + ? format.timestamp() + : format.timestamp({ + format: "DD/MM/YYYY HH:mm:ss.SSS", + }), format.ms(), utilities.format.nestLike("Worker", {}), ];