Skip to content

Instantly share code, notes, and snippets.

@jeroenbourgois
Created February 16, 2012 20:51
Show Gist options
  • Save jeroenbourgois/1847748 to your computer and use it in GitHub Desktop.
Save jeroenbourgois/1847748 to your computer and use it in GitHub Desktop.
hook for stdout
hook_stdout: (callback) ->
old_write = process.stdout.write
process.stdout.write = ((write) ->
return (string, encoding, fd) ->
write.apply(process.stdout, arguments)
winston.log('info', string)
callback(string, encoding, fd)
)(process.stdout.write)
return () => process.stdout.write = old_write
unhook: ->
@hook_stdout (string, encoding, fd) ->
util.debug('d')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment