Class: Rack::Logger

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

Overview

Sets up rack.logger to write to rack.errors stream

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Logger.



11
12
13
# File 'lib/rack/logger.rb', line 11

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

Instance Method Details

#call(env) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/rack/logger.rb', line 15

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

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