pino
pino copied to clipboard
chaning logging level of a multistream element at runtime
Is it possible to change the logging level of a multistream element at runtime? Consider the multistream example ...
var pino = require('pino')
var pretty = require('pino-pretty')
var streams = [
{stream: fs.createWriteStream('/tmp/info.stream.out')},
{stream: pretty() },
{level: 'debug', stream: fs.createWriteStream('/tmp/debug.stream.out')},
{level: 'fatal', stream: fs.createWriteStream('/tmp/fatal.stream.out')}
]
var log = pino({
level: 'debug' // this MUST be set at the lowest level of the
// destinations
}, pino.multistream(streams))
log.debug('this will be written to /tmp/debug.stream.out')
log.info('this will be written to /tmp/debug.stream.out and /tmp/info.stream.out')
log.fatal('this will be written to /tmp/debug.stream.out, /tmp/info.stream.out and /tmp/fatal.stream.out')
Could I at some point - while running - do something like streams[3].level = 'warn'
and expect log.error( ... )
to now also write to /tmp/fatal.stream.out
going forward? (I tried this, exactly, and it didn't work; I was wondering if I'm missing some API call to do this properly.)
I don't think that's supported but I would love to see a PR to add that functionality.
https://github.com/pinojs/pino-arborsculpture was written long before multistream or in-process transports.