From c1982596d59d2a72ffb313bd390d47214cc65a38 Mon Sep 17 00:00:00 2001 From: Valtteri Kantanen Date: Wed, 9 Oct 2024 17:03:55 +0300 Subject: [PATCH] [Backend] Improve logging --- services/backend/src/util/logger.js | 12 +++++++++--- .../components/Teachers/TeacherLeaderBoard/index.jsx | 8 ++------ 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/services/backend/src/util/logger.js b/services/backend/src/util/logger.js index 1c07f0bd9b..35a2ebbe2d 100644 --- a/services/backend/src/util/logger.js +++ b/services/backend/src/util/logger.js @@ -29,9 +29,15 @@ const logger = winston.createLogger({ format: combine( colorize(), timestamp({ format: isProduction ? 'D.M.YYYY,HH.mm.ss' : 'HH.mm.ss' }), - printf(({ level, message, timestamp, error }) => { - const log = `${timestamp} ${level}: ${message}` - return error?.stack ? `${log}\n${error.stack}` : log + printf(({ level, message, timestamp, error, meta }) => { + let log = `${timestamp} ${level}: ${message}` + if (error?.stack) { + log = `${log}\n${error.stack}` + } + if (Object.keys(meta || {}).length > 0) { + log = `${log}\n${JSON.stringify(meta, null, 2)}` + } + return log }) ), transports, diff --git a/services/frontend/src/components/Teachers/TeacherLeaderBoard/index.jsx b/services/frontend/src/components/Teachers/TeacherLeaderBoard/index.jsx index a6cad4e273..abc02206bf 100644 --- a/services/frontend/src/components/Teachers/TeacherLeaderBoard/index.jsx +++ b/services/frontend/src/components/Teachers/TeacherLeaderBoard/index.jsx @@ -48,12 +48,8 @@ export const TeacherLeaderBoard = () => { })) const lastUpdated = new Date(topTeachers?.updated).toLocaleString(undefined, { - year: 'numeric', - month: 'long', - day: 'numeric', - minute: 'numeric', - hour: 'numeric', - second: 'numeric', + dateStyle: 'long', + timeStyle: 'medium', }) return (