Closed Bhavikpatel576 closed 1 year ago
@Bhavikpatel576 , Please take a look at this https://github.com/pinojs/pino/blob/master/docs/transports.md
@Bhavikpatel576 ,
We can have a transport, that returns a duplex
log.js
const pino = require('pino')
const transport = pino.transport({
targets: [
// only my error logs are pushed to error-transport
{ target: './error-transport.js', level: 'error' },
]
})
pino(transport)
error-transport.js
const { PassThrough } = require("stream");
module.exports = async function () {
const tunnel = new PassThrough();
tunnel.on("data", (chunk) => {
// push to your desired destination
});
return tunnel
}
Thanks @couragecowardlydog!
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.
Hello everyone,
I'm trying to create a hook in Pino that sends a message to a Slack channel if a specific log level is used. I'm not very familiar with the Pino transport system, so I'm having some trouble figuring out how to achieve this.
From what I understand, the Pino transport setting replaces any existing settings, but I want to keep all my current logging settings intact while also running an asynchronous function if the log level is a warning.
Does anyone have any experience with this and could provide some guidance on how to achieve this? Any help would be greatly appreciated. Thank you!