From 409af3898ba0f818909787f1b47df8b342b71549 Mon Sep 17 00:00:00 2001 From: sarayourfriend Date: Sun, 31 Mar 2024 09:40:25 +1100 Subject: [PATCH] Narrow LoggerArgs types and fix bad revert --- src/backend/Logger.ts | 3 +-- src/backend/middlewares/RenderingMWs.ts | 3 ++- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/Logger.ts b/src/backend/Logger.ts index ddea11f3..b6ccb39e 100644 --- a/src/backend/Logger.ts +++ b/src/backend/Logger.ts @@ -11,8 +11,7 @@ if (forcedDebug === true) { ); } -// Match `console.log` inputs -export type LoggerArgs = Parameters[0] +export type LoggerArgs = (string | number | (() => string) | Record | Error); export type LoggerFunction = (...args: LoggerArgs[]) => void; export interface ILogger { diff --git a/src/backend/middlewares/RenderingMWs.ts b/src/backend/middlewares/RenderingMWs.ts index bb4ca0c1..12b26ad6 100644 --- a/src/backend/middlewares/RenderingMWs.ts +++ b/src/backend/middlewares/RenderingMWs.ts @@ -132,11 +132,12 @@ export class RenderingMWs { ): void { if (err instanceof ErrorDTO) { if (err.details) { + const logFn = Logger.logLevelForError(err.code) LoggerRouter.log(logFn, req, res); // use separate rendering for detailsStr const d = err.detailsStr; delete err.detailsStr; - console.log(err); + logFn(err); err.detailsStr = d; delete err.details; // do not send back error object to the client side