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