pino icon indicating copy to clipboard operation
pino copied to clipboard

prettyPrint does not print child object e.g. x-request-id

Open chetnawarade opened this issue 4 years ago • 3 comments

ERROR [1623809348111] (my-bar-logger/79874 on MBP-foo): "fake error" Error: "fake error" at Object. (/Users/foo/ss/my-bar/app/bar/tests/my-bar-rest-impl-learner-500-error-tests.js:13:42) at Object.invoke (/Users/foo/ss/my-bar/node_modules/sinon/lib/sinon/behavior.js:165:35) at functionStub (/Users/foo/ss/my-bar/node_modules/sinon/lib/sinon/stub.js:42:43) at Function.invoke (/Users/foo/ss/my-bar/node_modules/sinon/lib/sinon/proxy-invoke.js:50:47) at handlebarRequest (/Users/foo/ss/my-bar/node_modules/sinon/lib/sinon/proxy.js:285:26) at getLearnerbar (/Users/foo/ss/my-bar/app/bar/my-bar-rest-impl.js:45:28) at /Users/foo/ss/my-bar/node_modules/express-async-wrap/lib/index.js:15:14 at Layer.handle [as handle_request] (/Users/foo/ss/my-bar/node_modules/express/lib/router/layer.js:95:5) at next (/Users/foo/ss/my-bar/node_modules/express/lib/router/route.js:137:13) at Route.dispatch (/Users/foo/ss/my-bar/node_modules/express/lib/router/route.js:112:3)

with prettyPrint as false json contains x-request-id

{“level”:“error”,“time”:1623809549883,“pid”:80044,“hostname”:“MBP-foo,“name”:“my-bar-logger”,“x-request-id”:“dfc2e009-4309-4a24-b41b-c5183e23a0b2",“stack”:“Error: \“fake error\“\n at Object. (/Users/foo/ss/my-bar/app/bar/tests/my-bar-rest-impl-learner-500-error-tests.js:13:42)\n at Object.invoke (/Users/foo/ss/my-bar/node_modules/sinon/lib/sinon/behavior.js:165:35)\n at functionStub (/Users/foo/ss/my-bar/node_modules/sinon/lib/sinon/stub.js:42:43)\n at Function.invoke (/Users/foo/ss/my-bar/node_modules/sinon/lib/sinon/proxy-invoke.js:50:47)\n at handlebarRequest (/Users/foo/ss/my-bar/node_modules/sinon/lib/sinon/proxy.js:285:26)\n at getLearnerbar (/Users/foo/ss/my-bar/app/bar/my-bar-rest-impl.js:45:28)\n at /Users/foo/ss/my-bar/node_modules/express-async-wrap/lib/index.js:15:14\n at Layer.handle [as handle_request] (/Users/foo/ss/my-bar/node_modules/express/lib/router/layer.js:95:5)\n at next (/Users/foo/ss/my-bar/node_modules/express/lib/router/route.js:137:13)\n at Route.dispatch (/Users/foo/ss/my-bar/node_modules/express/lib/router/route.js:112:3)“,”type”:“Error”,“message”:“\”fake error\“”}

chetnawarade avatar Jun 16 '21 06:06 chetnawarade

What are we supposed to take away from this report? What is the data causing the error? What is the minimal reproduction case?

jsumners avatar Jun 16 '21 11:06 jsumners

When prettyPrint options are set as below e.g. and a child is created e.g. logger.child('somekey': 'some value') this child object/property isn't printed out. Posted prettPrint and json (prettyPrint: false) stack in previous comment to compare where child is set as 'x-request-id' this can be anything, i called out somekeyin this comment. Thanks for looking at this.

const logger = pino({
  prettyPrint: { levelFirst: true,
  forceColor: true }
})

vs.

const logger = pino({
  prettyPrint: false
})

chetnawarade avatar Jun 16 '21 16:06 chetnawarade

https://stackoverflow.com/help/minimal-reproducible-example

In short: please provide a short script than can be copied, pasted, and run by node index.js.

jsumners avatar Jun 16 '21 17:06 jsumners

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[bot] avatar Feb 18 '23 00:02 github-actions[bot]