Skip to content

Commit

Permalink
Only logging response body in development if json
Browse files Browse the repository at this point in the history
  • Loading branch information
ianwalter committed Sep 25, 2021
1 parent 7933144 commit 9d681a7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/dirty-terms-grin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@ianwalter/nrg-logger": patch
---

Only logging response body in development if json
5 changes: 4 additions & 1 deletion packages/nrg-logger/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,10 @@ module.exports = function nrgLogger (options = {}) {

if (shouldLog) {
ctx.logger.log(entry)
if (ctx.body) ctx.logger.debug('Response body', ctx.body)
const contentType = ctx.response.get('content-type')
if (ctx.body && contentType.includes('application/json')) {
ctx.logger.debug('Response body', ctx.body)
}
}
}
}
Expand Down

0 comments on commit 9d681a7

Please sign in to comment.