Skip to content

Instantly share code, notes, and snippets.

@damien
Created January 23, 2015 23:10
Show Gist options
  • Save damien/0a5d9fd72abe572e1bd8 to your computer and use it in GitHub Desktop.
Save damien/0a5d9fd72abe572e1bd8 to your computer and use it in GitHub Desktop.
Nicely formatted logger
logger = ActiveSupport::Logger.new(STDOUT)
logger.formatter = -> (severity, datetime, progname, msg) { format('[%-5.5{severity} %{timestamp}] %{msg}', severity: severity, timestamp: datetime.to_s(:db), msg: msg) + "\n" }
logger.unknown 'foo'
logger.fatal 'bar'
logger.error 'fizz'
logger.warn 'buzz'
logger.info 'alice'
logger.debug 'bob'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment