fix(#12): Implement structured logging with request correlation and security event marking
Some checks are pending
Docker Test / test (push) Waiting to run
Some checks are pending
Docker Test / test (push) Waiting to run
This commit is contained in:
parent
32480438c7
commit
0679332c77
3 changed files with 77 additions and 2 deletions
|
|
@ -5,7 +5,8 @@ function logger(req, res, next) {
|
|||
method: req.method,
|
||||
url: req.url,
|
||||
requestId: req.requestId,
|
||||
level: 'info'
|
||||
level: 'info',
|
||||
route: req.route ? req.route.path : 'unknown'
|
||||
}));
|
||||
res.on('finish', () => {
|
||||
const securityEvent = [401, 403].includes(res.statusCode);
|
||||
|
|
@ -16,7 +17,8 @@ function logger(req, res, next) {
|
|||
status: res.statusCode,
|
||||
requestId: req.requestId,
|
||||
level: res.statusCode >= 400 ? 'error' : 'info',
|
||||
securityEvent: securityEvent
|
||||
securityEvent: securityEvent,
|
||||
route: req.route ? req.route.path : 'unknown'
|
||||
}));
|
||||
});
|
||||
next();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue