Skip to content

Commit 9453d1f

Browse files
committed
added object logging to logging tools ✔
1 parent e49c17d commit 9453d1f

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/tools/logging.js

+13-1
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,26 @@ export function registerLogging(app) {
1010
if (config.get('logRequests')) app.use(requestLogger);
1111
}
1212

13+
function formatObject(param) {
14+
if (typeof param === 'string') {
15+
return param;
16+
}
17+
18+
if (param instanceof Error) {
19+
return param.stack ? param.stack : JSON.stringify(param, null, 2);
20+
}
21+
22+
return JSON.stringify(param, null, 2);
23+
}
24+
1325
const prettyConsoleTransport = new transports.Console({
1426
format: combine(
1527
colorize(),
1628
json(),
1729
printf(info => {
1830
return `[${new Date().toLocaleDateString('en-GB')} ${new Date().toLocaleTimeString(
1931
'en-US'
20-
)}] ${info.level} | ${info.message}`;
32+
)}] ${info.level} | ${formatObject(info.message)}`;
2133
})
2234
)
2335
});

0 commit comments

Comments
 (0)