Skip to content

Instantly share code, notes, and snippets.

@8bitDesigner
Created September 13, 2013 20:49
Show Gist options
  • Select an option

  • Save 8bitDesigner/6555867 to your computer and use it in GitHub Desktop.

Select an option

Save 8bitDesigner/6555867 to your computer and use it in GitHub Desktop.
Redefine stdout and stderr as writeable file streams
var fs = require('fs')
, logfile = './logs/output.log'
, errfile = './logs/error.log'
function logger(dest) {
return function() {
return fs.createWriteStream(dest, {flags: 'a'});
}
}
// Redefine stdout and stderr as our output loggers
process.__defineGetter__('stdout', logger(logfile))
process.__defineGetter__('stderr', logger(errfile))
@d48

d48 commented Sep 13, 2013

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment