Skip to content

Commit b618251

Browse files
committed
chore: fix debug log %s formatting
Ticket: WP-00000
1 parent 8f8da0f commit b618251

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

src/logger.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,17 @@ winston.addColors(colors);
3232
const format = winston.format.combine(
3333
winston.format.timestamp({ format: 'YYYY-MM-DD HH:mm:ss:ms' }),
3434
winston.format.colorize({ all: true }),
35-
winston.format.printf(
36-
(info: winston.Logform.TransformableInfo) => `${info.timestamp} ${info.level}: ${info.message}`,
37-
),
35+
winston.format.printf((info: winston.Logform.TransformableInfo) => {
36+
// Handle both string interpolation and object logging
37+
const message = typeof info.message === 'string' ? info.message : JSON.stringify(info.message);
38+
39+
// If there are additional arguments, format them
40+
const args = (info[Symbol.for('splat')] as any[]) || [];
41+
const formattedMessage =
42+
args.length > 0 ? message.replace(/%s/g, () => String(args.shift() || '')) : message;
43+
44+
return `${info.timestamp} ${info.level}: ${formattedMessage}`;
45+
}),
3846
);
3947

4048
// Define which transports the logger must use

0 commit comments

Comments
 (0)