ruby > thoughts.find_all(&:sfw?).to_blog
 => #<URI::HTTP:0x00001 URL: http://MichaelXavier.net >
ruby > MichaelXavier.info
 =>  [ GitHub , Resume , Email ]
ruby > _

Snippet: Rack::CommonLogger in Sinatra
02|05|2010 — 0 comments  

Categories: ruby, sinatra, code snippet

If you wanted to log stuff like you would in rails and sinatra, here would be a very clean way to do it.


            configure do
              Dir.mkdir('log') unless File.exists?('log')
            end
            
            configure :test do
              use Rack::CommonLogger, File.new('log/test.log', 'w')
            end
            
            configure :development do
              use Rack::CommonLogger, File.new('log/development.log', 'w')
            end
            
            configure :production do
              use Rack::CommonLogger, File.new('log/production.log', 'w')
            end
            

More updates to come once I get out of midterm hell next week.

Comments Comments RSS Feed

Add Comment

(required)
(required, won't be displayed)

(Use Markdown syntax)