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

Understanding how formatters and serializers work #991

Closed
btilford opened this issue Mar 25, 2021 · 2 comments
Closed

Understanding how formatters and serializers work #991

btilford opened this issue Mar 25, 2021 · 2 comments

Comments

@btilford
Copy link

Sorry I know you get a lot of these questions but every time I think I understand how things are going to be output it's not what I expected.

I'm trying to figure out why (in Stackdriver) the merge object is empty except for the things set during logger creation. And why I don't ever see error information logged. I may very well have a plugin or misconfiguration, but I've spent hours and hours over the last 6 months coming back to this.

Should logger.error({err, prop1: '123'}, 'Error!!! %s', err.message) end up outputting something like.

{
 "level": 50,
  "time": 1616629624712,
  "err": {"message": "<error message>", "stack": "<stack\ntrace>" },
  "prop1" : "123",
  "name": "<set when logger was created>",
  "req": { "headers": {}, "url": "<>", "method": "GET" },
  "message" : "Error!!! <error message>",
}

Currently, my output omits both err and prop1

{
 "level": 50,
  "time": 1616629624712,
  "name": "<set when logger was created>",
  "req": { "headers": {}, "url": "<>", "method": "GET" },
  "message" : "Error!!! <error message>",
}
@jsumners
Copy link
Member

Can you provide a full reproduction? I am not seeing this issue.

index.js

const log = require('pino')()

const err = Error('boom')
log.info({ err, foo: 'foo' }, 'Error!!! %s', err.message)
❯ node index.js | jq
{
  "level": 30,
  "time": 1616673421539,
  "pid": 90316,
  "hostname": "mini2018",
  "err": {
    "type": "Error",
    "message": "boom",
    "stack": "Error: boom\n    at Object.<anonymous> (/private/tmp/25/index.js:3:13)\n    at Module._compile (internal/modules/cjs/loader.js:1063:30)\n    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)\n    at Module.load (internal/modules/cjs/loader.js:928:32)\n    at Function.Module._load (internal/modules/cjs/loader.js:769:14)\n    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)\n    at internal/main/run_main_module.js:17:47"
  },
  "foo": "foo",
  "msg": "Error!!! boom"
}

@github-actions
Copy link

This issue 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 Mar 20, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants