Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix missing object wrapper for errors in pino log #1180

Merged
merged 1 commit into from
Sep 22, 2018

Conversation

ofavre
Copy link
Contributor

@ofavre ofavre commented Sep 22, 2018

log is a pino logger, the first argument is a mapping, so in order to give it an error object, we must give it an object with an err field, otherwise the error object itself is dissected as if it were a mapping.

This commit fixes places where this has been forgotten.
I only changed source files, not test files because it's not a big deal there.

Checklist

  • run npm run test and npm run benchmark
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message and code follows Code of conduct

npm run benchmark exits this way on my machine, on my branch just like on master:

[0] {"level":30,"time":1537595975197,"msg":"request completed","pid":30338,"hostname":"Ofavre-Home-T5500","reqId":38361,"res":{"statusCode":200},"responseTime":0.18976199626922607,"v":1}
[0] {"level":50,"time":1537595975197,"msg":"client error","pid":30338,"hostname":"Ofavre-Home-T5500","type":"Error","stack":"Error: write EPIPE\n    at WriteWrap.afterWrite [as oncomplete] (net.js:835:14)","errno":"EPIPE","code":"EPIPE","syscall":"write","v":1}
[0] {"level":50,"time":1537595975198,"msg":"client error","pid":30338,"hostname":"Ofavre-Home-T5500","type":"Error","stack":"Error: read ECONNRESET\n    at TCP.onread (net.js:659:25)","errno":"ECONNRESET","code":"ECONNRESET","syscall":"read","v":1}
[0] node ./examples/simple.js exited with code SIGTERM

Benchmarking such a change makes no sense anyway.

log is a pino logger, the first argument is a mapping, so in order to
give it an error object, we must give it an object with an 'err' field.

This commit fixes places where this has been forgotten, except in test
files.
Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

log.error(err) is actually valid in pino, but it's less configurable.

Copy link
Contributor

@cemremengu cemremengu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@cemremengu cemremengu merged commit 889f16d into fastify:master Sep 22, 2018
@github-actions
Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 14, 2022
@Eomm Eomm added the semver-minor Issue or PR that should land as semver minor label Apr 1, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
semver-minor Issue or PR that should land as semver minor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants