45 lines
1.1 KiB
TypeScript
45 lines
1.1 KiB
TypeScript
import pino from 'pino'
|
|
|
|
const pinoConfigProd: pino.LoggerOptions = {
|
|
transport: {
|
|
targets: [
|
|
{
|
|
target: 'pino/file', options: {
|
|
destination: './production.log', mkdir: true, minLength: 4096, sync: false,
|
|
},
|
|
},
|
|
],
|
|
},
|
|
level: 'error',
|
|
redact: {
|
|
paths: ['password', '*.password'], remove: true,
|
|
},
|
|
}
|
|
|
|
const pinoConfigDev: pino.LoggerOptions = {
|
|
redact: {
|
|
paths: ['password', '*.password'], remove: false,
|
|
},
|
|
// formatters: {
|
|
// bindings: (bindings) => {
|
|
// return { pid: bindings.pid, host: bindings.hostname, node_version: process.version }
|
|
// },
|
|
// },
|
|
transport: {
|
|
targets: [
|
|
{
|
|
//target: 'pino/file',
|
|
target: 'pino-pretty', options: { destination: `./pretty.log`, mkdir: true, colorize: false }, level: 'error',
|
|
}, {
|
|
target: 'pino-pretty', level: 'trace',
|
|
}],
|
|
},
|
|
}
|
|
|
|
const journal = process.env.NODE_ENV === 'production'
|
|
? pino(pinoConfigProd)
|
|
: pino(pinoConfigDev)
|
|
|
|
export default journal
|
|
|
|
// TODO: wait for newer version of https://betterstack.com/docs/logs/javascript/pino/
|