Skip to content

Instantly share code, notes, and snippets.

@brettinternet
Created March 7, 2017 23:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brettinternet/2f349bb55f1d5011a3b98c8de456dbfb to your computer and use it in GitHub Desktop.
Save brettinternet/2f349bb55f1d5011a3b98c8de456dbfb to your computer and use it in GitHub Desktop.
Debugging in node with a lightweight logger
const fs = require('fs'),
util = require('util'),
file = fs.createWriteStream(__dirname + '/error.log', {flags : 'w'}),
sout = process.stdout,
err = d => {
file.write(util.format(d) + '\n')
sout.write(util.format(d) + '\n')
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment