Advertisement
Guest User

Untitled

a guest
Aug 16th, 2017
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. const pino = require('pino');
  2. const childProcess = require('child_process');
  3. const PassThrough = require('stream').PassThrough;
  4.  
  5. const logPath = `${process.cwd()}/log`;
  6. const logThrough = new PassThrough();
  7. const log = pino({name: 'spybot'}, logThrough);
  8.  
  9. const child = childProcess.spawn(process.execPath, [
  10. require.resolve('pino-tee'),
  11. 'warn', `${logPath}/warn.log`,
  12. 'error', `${logPath}/error.log`,
  13. 'fatal', `${logPath}/fatal.log`
  14. ], {
  15. cwd: __dirname,
  16. env: process.env
  17. });
  18.  
  19. const pretty = pino.pretty();
  20.  
  21. pretty.pipe(process.stdout);
  22. logThrough.pipe(child.stdin);
  23. logThrough.pipe(pretty);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement