Skip to content

Instantly share code, notes, and snippets.

@chrisabrams
Last active December 20, 2015 19:09
Show Gist options
  • Save chrisabrams/6181585 to your computer and use it in GitHub Desktop.
Save chrisabrams/6181585 to your computer and use it in GitHub Desktop.
Write console.logs from your app/tests running in Mocha to a file.
fs = require 'fs'
util = require "util"
log = fs.createWriteStream(process.cwd() + "/test/stdout.log")
console.log = console.info = (t) ->
out = undefined
if t and ~t.indexOf("%")
out = util.format.apply(util, arguments)
process.stdout.write out + "\n"
return
else
out = Array::join.call(arguments, " ")
out and log.write(out + "\n")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment