Snippet: Rack::CommonLogger in Sinatra
February 5, 2010
It’s been a little while. I’ve been completely swamped with school and work, but I realized there wasn’t really any code samples I could find for using Rack::CommonLogger in Sinatra. Solution after the jump.
If you wanted to log stuff like you would in rails and sinatra, here would be a very clean way to do it.
do
configure Dir.mkdir('log') unless File.exists?('log')
end
:test do
configure Rack::CommonLogger, File.new('log/test.log', 'w')
use end
:development do
configure Rack::CommonLogger, File.new('log/development.log', 'w')
use end
:production do
configure Rack::CommonLogger, File.new('log/production.log', 'w')
use end
More updates to come once I get out of midterm hell next week.