Class: AsyncRack::Logger

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

Instance Method Summary collapse

Instance Method Details

#async_callback(result) ⇒ Object



5
6
7
8
# File 'lib/async_rack/logger.rb', line 5

def async_callback(result)
  @logger.close
  super
end

#call(env) ⇒ Object



10
11
12
13
14
15
16
17
18
19
# File 'lib/async_rack/logger.rb', line 10

def call(env)
  @logger = ::Logger.new(env['rack.errors'])
  @logger.level = @level
  env['rack.logger'] = @logger
  @app.call(env) # could throw :async
  @logger.close
rescue Exception => error # does not get triggered by throwing :async (ensure does)
  @logger.close
  raise error
end