-
Notifications
You must be signed in to change notification settings - Fork 70
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
Usage with Pino as a Transport #99
Comments
Please check out adzejs as an alternative logger to Pino. It just works with everything. Here's an example of setting up this library with Adze:
|
I wanted to use this library as a Pino Transport.
The problem is that Pino can only accept streams using the streams API which then doesn't allow the usage of other transports.
So if for example I wanted to save the logs to a file and also pretty-print them, I would have to setup both the
FileStreamRotator
and the pretty-print as streams using the stream API and I can't just setup the pretty-print as a normal transport.And in my app I have 7 different transports and I really didn't want to have to change the code to use the stream API.
So here is what I came up with:
Create a file named 'logger.ts' and add this code to it:
Since Pino forces us to pass the
target
prop as string that points to a transport file, instead of creating a new file just for this, I export the stream as the default of this file and then point the target to myself.It's super hacky but that's the only way I found that wouldn't require creating a new file and then having to deal with windows/mac/linux file paths nonsense.
If anyone has a better, cleaner solution, I would love to hear it . Thanks.
The text was updated successfully, but these errors were encountered: