Created
November 5, 2015 18:37
-
-
Save ryanhamley/d159efd41b0c67b0067d to your computer and use it in GitHub Desktop.
Log to a file with Node
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var log_file = fs.createWriteStream(__dirname + '/debug.log', {flags : 'w'}); | |
var log_stdout = process.stdout; | |
console.log = function(d) { // | |
log_file.write(util.format(d) + '\n'); | |
log_stdout.write(util.format(d) + '\n'); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment