Created
February 11, 2014 14:49
-
-
Save nathanl/8936205 to your computer and use it in GitHub Desktop.
Nice Ruby log formatting
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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