Closed robcalcroft closed 6 years ago
You should be handling logs downstream, e.g. node your_app.js > out.log
. Thus, you can:
const isdebug = require('isdebug')
const pino = require('pino')
module.exports = pino({
level: (isdebug) ? 'debug' : 'info',
prettyPrint: isdebug
})
Right ok, i'll work out a solution from that. Thanks 😄
More examples I'm using in a few projects:
const pino = require('pino')
module.exports = function (config) {
const pinoConfig = {
level: config.level
}
if (config.pretty) {
pinoConfig.prettyPrint = {
forceColor: true,
formatter: require('./dev_string_formatter')
}
}
return pino(pinoConfig)
}
const pino = require('pino')
module.exports = function loggerFactory (logOptions = {}) {
if ([false, 'false'].includes(logOptions.enabled)) return pino({enabled: false})
if (![true, 'true'].includes(logOptions.pretty)) return pino(logOptions)
const stream = require('pino-colada')()
stream.pipe(process.stdout)
return pino(logOptions, stream)
}
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.
Currently we use
to expose the logger, but I'd like to be able to have pino log to command line in development where performance is not an issue, is this possible?