Skip to content

Instantly share code, notes, and snippets.

@8bitDesigner
Last active December 10, 2015 21:29
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 8bitDesigner/4495287 to your computer and use it in GitHub Desktop.
Save 8bitDesigner/4495287 to your computer and use it in GitHub Desktop.
Drop in replacement for `console` logging in a NodeJS application
var console = require(__dirname + '/logger')
// All three of these do the same thing
console.log(1, 2, 3) // Gets rewritten as console.log('info', 1, 2, 3)
console.log('info', 1, 2, 3) // Indentical as below
console.info(1, 2, 3)
// Works as well
console.warn('oh noes')
console.error('oh poop!')
winston = require "winston"
options =
timestamp: true
colorize: true
# Re-configure console transport
winston.remove winston.transports.Console
winston.add winston.transports.Console, options
winston.setLevels winston.config.syslog.levels
# Default log level to info
winston.oldlog = winston.log
winston.log = (args...) ->
args.unshift 'info' if args[0] not in Object.keys(winston.config.syslog.levels)
winston.oldlog.apply winston, args
module.exports = winston
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment