Skip to content

Commit

Permalink
fix: log error instead of warn on 500s (#75)
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanhallcs authored and mcollina committed May 11, 2019
1 parent fbb8367 commit 1994c47
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ async function register (server, options) {

server.events.on('log', function (event) {
if (event.error) {
logger.warn({ err: event.error })
logger.error({ err: event.error })
} else {
logEvent(logger, event)
}
Expand All @@ -96,7 +96,7 @@ async function register (server, options) {
request.logger = request.logger || logger.child({ req: request })

if (event.error && isEnabledLogEvent(options, 'request-error')) {
request.logger.warn({
request.logger.error({
err: event.error
}, 'request error')
} else if (event.channel === 'app') {
Expand Down
4 changes: 2 additions & 2 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ experiment('logs each request', () => {
await registerWithSink(server, 'info', (data, enc, cb) => {
if (count === 0) {
expect(data.err.message).to.equal('boom')
expect(data.level).to.equal(40)
expect(data.level).to.equal(50)
expect(data.msg).to.equal('request error')
} else {
expect(data.res.statusCode).to.equal(500)
Expand Down Expand Up @@ -381,7 +381,7 @@ experiment('logs through server.log', () => {
expect(data.err.message).to.equal('foobar')
expect(data.err.stack).to.exist()
// highest level tag
expect(data.level).to.equal(40)
expect(data.level).to.equal(50)
resolver()
})

Expand Down

0 comments on commit 1994c47

Please sign in to comment.