Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const pino = require('pino');
- const childProcess = require('child_process');
- const PassThrough = require('stream').PassThrough;
- const logPath = `${process.cwd()}/log`;
- const logThrough = new PassThrough();
- const log = pino({name: 'spybot'}, logThrough);
- const child = childProcess.spawn(process.execPath, [
- require.resolve('pino-tee'),
- 'warn', `${logPath}/warn.log`,
- 'error', `${logPath}/error.log`,
- 'fatal', `${logPath}/fatal.log`
- ], {
- cwd: __dirname,
- env: process.env
- });
- const pretty = pino.pretty();
- pretty.pipe(process.stdout);
- logThrough.pipe(child.stdin);
- logThrough.pipe(pretty);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement