bogeychan / elysia-logger

A plugin for Elysia.js for logging using the pino library
https://npmjs.com/package/@bogeychan/elysia-logger
MIT License
114 stars 7 forks source link

Feature: named logger and request context #1

Closed LoganArnett closed 1 year ago

LoganArnett commented 1 year ago

Found some options that Pino offers were not being tracked in what I usually see in the logs. I added an option to include a random request Id along with the general context of a request with each log that is fired during that request. I also found that for possible child logger cases it would be nice to have a custom name option for the parent logger that is attached to the context.

the request context output on each log for a given request allows for an output like this:

requestId: "q2hqvwljmdv3w7bw580p"
path: "/profile/12345"
query: {
  "search": "hello"
}
params: {
  "userId": "12345"
}
// or like this if no query or params
requestId: "q2hqvwljmdv3w7bw580p"
path: "/profile"
query: {}
params: {}
bogeychan commented 1 year ago

Hi, thanks for your contribution! I changed a few things to make it more adaptable for others.