1
0
mirror of https://github.com/xuthus83/pigallery2.git synced 2024-11-03 21:04:03 +08:00

Always use Logger class and try to log once per event

This unifies logging across the backend to always use the Logger class,
always only logs to stdout (rather than an inconsistent mix of stdout
and stderr, depending on whether console.error was used), and removes
logging where two log events happened for the same message

For example, this pattern:

```js
Logger.error("Whoops, something went wrong:")
console.error(err)
```

That causes two separate log events, and depending on the log transport
used, could cause relevant log messages to get split across multiple
events and therefore be harder (usually just more tedious) to connect
and debug in production environments.
This commit is contained in:
sarayourfriend 2024-03-29 17:45:08 +11:00
parent ba6e7c03ec
commit b0c2f8da04
No known key found for this signature in database

View File

@ -134,12 +134,11 @@ export class RenderingMWs {
if (err.details) {
const logFn = Logger.logLevelForError(err.code)
logFn('Handled error:');
LoggerRouter.log(logFn, req, res);
// use separate rendering for detailsStr
const d = err.detailsStr;
delete err.detailsStr;
logFn(err);
logFn('Handled error:\n', err);
LoggerRouter.log(logFn, req, res);
err.detailsStr = d;
delete err.details; // do not send back error object to the client side