Class: Rack::ErrorLogger

Inherits:
RackLogger show all
Defined in:
lib/simple_rack_logger/error_logger.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from RackLogger

flush

Constructor Details

#initialize(app, logger, *filters) ⇒ ErrorLogger

Returns a new instance of ErrorLogger.



7
8
9
# File 'lib/simple_rack_logger/error_logger.rb', line 7

def initialize(app, logger, *filters)
  super
end

Instance Attribute Details

#loggerObject (readonly)

Returns the value of attribute logger.



5
6
7
# File 'lib/simple_rack_logger/error_logger.rb', line 5

def logger
  @logger
end

Instance Method Details

#call(env) ⇒ Object



11
12
13
14
15
16
17
18
19
# File 'lib/simple_rack_logger/error_logger.rb', line 11

def call(env)
  begin
    @app.call(env)
  rescue => e
    logger.error("#{e.message}\r\n#{e.backtrace.join("\r\n")}")
    logger.flush
    raise e
  end
end