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

Support nestjs-pino #106

Closed
GauBen opened this issue Apr 23, 2022 · 1 comment
Closed

Support nestjs-pino #106

GauBen opened this issue Apr 23, 2022 · 1 comment

Comments

@GauBen
Copy link

GauBen commented Apr 23, 2022

Hey there!

Could you please add support for nestjs-pino?

It works nicely out of the box. I use it with -m '{"ns":"context"}' to print the context, but it looks weird on http requests that have no context:

image

Maybe add a default [HTTP] context (in another color) for http requests?


Edit: logs have a property req.id that allows correlating logs to requests, it might be interesting to display it

@dnjstrom
Copy link
Owner

Hi

Sorry for the delay in getting back to you regarding this issue. Not sure if still relevant but I believe adding HTTP to the ns property by default would be making too many assumptions about how the logger is going to be used. If a different user doesn't use the ns property then they would just get the reverse issue that you're seeing. Instead, in this case I believe setting the ns property of the log object could rather be configured as part of setting up pino-http. You might, for instance, configure pino-http with a child logger defaulting the ns property to HTTP.

const httpLogger = require('pino-http')({
  logger: parentLogger.child({ns: 'HTTP'})
})

Similarly, you might want to consider configuring the rename or duplication of context to ns using something like the formatters config of pino.

I like your idea about displaying the req.id property! Maybe something like the below where 1234 is the request id? 🤔

17:42:59 Info: GET(1234) /ping 200 22ms

I'll close this issue since it was opened a long time ago and might not be relevant anymore, but feel free to open it again if you'd like to continue the discussion 👍

@dnjstrom dnjstrom closed this as not planned Won't fix, can't repro, duplicate, stale Nov 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants