From 64ae54a82aa97dce00818bde3b37dd3e686c0054 Mon Sep 17 00:00:00 2001 From: Volodymyr Kolesnykov Date: Fri, 12 Jun 2026 03:01:01 +0300 Subject: [PATCH] fix(logger): remove timestamp from production log format --- __tests__/logger.spec.ts | 2 +- src/logger/index.ts | 9 +++------ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/__tests__/logger.spec.ts b/__tests__/logger.spec.ts index ddc0a286..f9a567a7 100644 --- a/__tests__/logger.spec.ts +++ b/__tests__/logger.spec.ts @@ -74,7 +74,7 @@ void describe( 'src/logger', async () => { assert( typeof message === 'string', 'Expected log message to be a string' ); match( message, - /^\w{3}, \d{2} \w{3} \d{4} \d{2}:\d{2}:\d{2} GMT go:app {"message":"my message","level":"info","app":"go","app_type":"app","message_type":"info","app_process":"master","app_worker":"master"}$/ + /^go:app {"message":"my message","level":"info","app":"go","app_type":"app","message_type":"info","app_process":"master","app_worker":"master"}$/ ); } ); } ); diff --git a/src/logger/index.ts b/src/logger/index.ts index 648f58d5..62765c70 100644 --- a/src/logger/index.ts +++ b/src/logger/index.ts @@ -1,9 +1,8 @@ import nodeCluster from 'node:cluster'; -import { createLogger, format, transports } from 'winston'; +import { createLogger, format, transports, type Logger } from 'winston'; import type { ClusterLike, LoggerOptions } from './types'; import type { TransformableInfo } from 'logform'; -import type { Logger } from 'winston'; const { combine, timestamp, printf, splat } = format; @@ -69,14 +68,12 @@ const localLoggingFormat = printf( output => { // Logging format for production const prodLoggingFormat = printf( output => { const logOutput = output as LogEntry; - const { timestamp: time, app, app_type: type } = logOutput; + const { app, app_type: type } = logOutput; // Can't include the timestamp in the JSON delete logOutput.timestamp; - return `${ String( time ) } ${ String( app ) }:${ String( type ) } ${ JSON.stringify( - logOutput - ) }`; + return `${ String( app ) }:${ String( type ) } ${ JSON.stringify( logOutput ) }`; } ); function createGoLogger(