One day I was sitting around trying to get some logging and output done on a rakefile, and getting tired of doing log.info("blah blah").tap{|t| puts t}, so I looked into log4r, and decided to use it. So here we are.
Set up log4r the way I like:
- Info Messages to stdout with no decoration
- All other messages to stderr
- Formatted messages to log/APP.log
Logging object is available on the constant Log
.
Download and copy the gist of log4r_setup.rb
into your project's load path someplace (like lib/
).
Add this line to your application's Gemfile:
gem 'log4r'
And then execute:
$ bundle
Or install it yourself as:
$ gem install log4r
Change the log4r_setup.rb
file to your personal tastes.
Add the following to your code:
require 'log4r-setup'
Then use the following to log things:
Log.info "blah blah"
Log.error "WHOOPS!"
Whatever, it's a gist, use it how you'd like. No license, no restrictions.