Skip to content

Instantly share code, notes, and snippets.

@kaworu
Created November 5, 2015 12:12
Show Gist options
  • Save kaworu/89e30265b9a6ca8f526d to your computer and use it in GitHub Desktop.
Save kaworu/89e30265b9a6ca8f526d to your computer and use it in GitHub Desktop.
var fs = require("fs");
var dest = "./test.log";
var stream = fs.createWriteStream(dest, {flags: 'a'});
var newcons = new console.Console(stream, stream);
// all the stuff documented at https://nodejs.org/api/console.html
[
'log', 'info', 'error', 'warn', 'dir',
'time', 'timeEnd', 'trace', 'assert'
].forEach(function (n) {
console[n] = newcons[n];
});
console.log("OHAI");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment