Class: Sinatra::Middleware::Logger

Inherits:
Object
  • Object
show all
Defined in:
lib/sinatra/middleware/logger.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, level = ::Logger::INFO) ⇒ Logger

Returns a new instance of Logger.



8
9
10
# File 'lib/sinatra/middleware/logger.rb', line 8

def initialize(app, level = ::Logger::INFO)
  @app, @level = app, level
end

Instance Method Details

#call(env) ⇒ Object



12
13
14
15
16
17
18
# File 'lib/sinatra/middleware/logger.rb', line 12

def call(env)
  logger = ::Logger.new(env[Rack::RACK_ERRORS])
  logger.level = @level

  env[Rack::RACK_LOGGER] = logger
  @app.call(env)
end