Closed lffg closed 5 years ago
Hello guys,
I recently discovered this library, but I couldn't find any way to create a pino instance that outputs to the console (pretty) and into a file.
Is there a way to do that?
I tried this (and works), but it not pretty-prints into the console:
import { spawn } from 'child_process'; import path from 'path'; import { PassThrough } from 'stream'; import pino from 'pino'; const logPath = path.join.bind(undefined, __dirname, '..', 'temp', 'logs'); const logThrough = new PassThrough(); export const log = pino( { name: 'thod' // prettyPrint: { // colorize: true, // levelFirst: true, // translateTime: true // } }, logThrough ); const child = spawn( process.execPath, [ require.resolve('pino-tee'), 'warn', logPath('warn.log'), 'error', logPath('error.log'), 'fatal', logPath('fatal.log') ], { cwd: process.cwd(), env: process.env } ); logThrough.pipe(child.stdin);
When I uncomment those lines, the logger stops dumping into the files...
How can I solve that problem?
PS: I want to log into the console when process.env.NODE_ENV === 'development'.
process.env.NODE_ENV === 'development'
Thanks in advance for any help or guiding. :)
check out https://github.com/pinojs/pino-multi-stream
Thanks! o/
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 guys,
I recently discovered this library, but I couldn't find any way to create a pino instance that outputs to the console (pretty) and into a file.
Is there a way to do that?
I tried this (and works), but it not pretty-prints into the console:
When I uncomment those lines, the logger stops dumping into the files...
How can I solve that problem?
PS: I want to log into the console when
process.env.NODE_ENV === 'development'
.Thanks in advance for any help or guiding. :)