Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
/* istanbul ignore if */
if (process.env.NODE_ENV === 'production') {
if (!fs.existsSync(logDir)) mkdirp.sync(logDir)
streams = [
{level: 'info', stream: fs.createWriteStream(`logs/${date}-info.log`, streamOpt)},
{level: 'error', stream: fs.createWriteStream(`logs/${date}-error.log`, streamOpt)}
]
}
module.exports = koaPinoLogger({
name: 'Easy Mock',
level: process.env.NODE_ENV === 'test' ? 'silent' : /* istanbul ignore next */ 'info',
genReqId: req => req.headers['x-request-id'] || uuid.v4()
}, multistream(streams))
base: null,
}
let loggerStreams: Streams = [{ stream: process.stdout }]
if (options.sentryOptions) {
loggerStreams.push({
level: 'error',
stream: createWriteStream({
...options.sentryOptions,
stackAttributeKey: 'err',
}),
})
}
if (options.streams) loggerStreams = loggerStreams.concat(options.streams)
this.inner = pino(loggerOptions, pinoms.multistream(loggerStreams))
}
export default opts => Pino({ name, ...opts }, multistream(streams));