I'm trying to log async requests to my sinatra app. I'm using sinatra synchrony which is working great, but I don't see any of my request info. This post shows a solution to this but my sorry newb self is unable to get it to work!
app.rb
require_relative 'logger' # middleware
class MyApp < Sinatra::Base
register Sinatra::Synchrony # async http requests up in this!
use Logger::Middleware
...
end
On rackup I get:
/Users/nflacco/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/logger.rb:197:in `<top (required)>': Logger is not a class (TypeError)
I looked around a little bit but I didn't see a quick answer on using middleware with a class based sinatra app. Thanks!
Update: I messed around a little with Rack:CommonLogger and got it to show my requests to the server (even with sinatra-synchrony) but nothing was getting written to file. Hmmmmm.
app.rb
configure do
Dir.mkdir('log') unless File.exists?('log')
use Rack::CommonLogger, Logger.new('log/elphi-api.log')
end