Skip to content

Commit

Permalink
feat(logs): log request headers (#130)
Browse files Browse the repository at this point in the history
  • Loading branch information
serge1peshcoff authored Sep 29, 2020
1 parent 9a29756 commit f8242e4
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
3 changes: 2 additions & 1 deletion config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ const config = {
'postgres.password',
'access_token',
'refresh_token',
'bugsnag_key'
'bugsnag_key',
'cookie'
],
bugsnag_key: process.env.BUGSNAG_KEY_CORE || 'CHANGEME'
},
Expand Down
3 changes: 2 additions & 1 deletion lib/logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ const filterFields = (body) => {

logger.addSerializers({
body: (body) => filterFields(body),
config: (config) => filterFields(config)
config: (config) => filterFields(config),
headers: (headers) => filterFields(headers)
});

module.exports = logger;
1 change: 1 addition & 0 deletions lib/morgan.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ module.exports = morgan((tokens, req, res) => {
status: tokens.status(req, res),
length: tokens.res(req, res, 'content-length'),
'response-time': tokens['response-time'](req, res),
headers: req.headers,
user,
body
}, 'Request processed');
Expand Down

0 comments on commit f8242e4

Please sign in to comment.