Skip to content

Instantly share code, notes, and snippets.

@nathanl
Created February 11, 2014 14:49
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 nathanl/8936205 to your computer and use it in GitHub Desktop.
Save nathanl/8936205 to your computer and use it in GitHub Desktop.
Nice Ruby log formatting
require 'logger'
l = Logger.new(STDOUT)
l.formatter = proc { |severity, datetime, progname, msg|
dt = datetime.strftime('%Y-%b-%d@%H:%M:%S:%z')
"#{[severity,dt,progname,msg].join(' ').squeeze(' ')}\n"
}
l.info "woot" #=> INFO 2014-Feb-11@09:48:32:-0500 woot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment