Skip to content

Instantly share code, notes, and snippets.

@kastner
Created January 4, 2010 08:26
Show Gist options
  • Save kastner/268403 to your computer and use it in GitHub Desktop.
Save kastner/268403 to your computer and use it in GitHub Desktop.
# sometimes you really _do_ want a global...
# alternately, stick it as a method on a Module somewhere, App.logger or whatever, but it's still just as much of a smell.
# replace STDERR with your filename of choice.
$logger = Logger.new(STDERR)
$logger.formatter = proc { |severity, datetime, progname, msg|
"#{severity} - #{progname} - [#{datetime.strftime("%d/%m/%Y %H:%M:%S")}] #{msg}\n"
}
run(Rack::Builder.new {
use Rack::CommonLogger, $logger
# ...
})
# and then just $logger.debug('hi there!') from wherever you need to debug shit.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment