Skip to content

Instantly share code, notes, and snippets.

@falsecz
Created February 13, 2014 19:36
Show Gist options
  • Save falsecz/8982222 to your computer and use it in GitHub Desktop.
Save falsecz/8982222 to your computer and use it in GitHub Desktop.
tty = require 'tty'
loggerFd = () ->
fd = 3
return {log: console.log.bind console} unless tty.isatty fd
log: (o) ->
stream = tty.WriteStream 3
stream.readable = false
stream.read = null;
stream._type = 'pipe'
stream.on 'error', (err) ->
console.log err.stack
stream.write "3:" + o + "\n"
logger = loggerFd()
logger.log 'mrdka'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment