Class: Tennpipes::Logger::Rack

Inherits:
Object
  • Object
show all
Defined in:
lib/tennpipes-base/logger.rb

Overview

Tennpipes::Logger::Rack forwards every request to an app given, and logs a line in the Apache common log format to the logger, or rack.errors by default.

Instance Method Summary collapse

Constructor Details

#initialize(app, uri_root) ⇒ Rack

Returns a new instance of Rack.



444
445
446
447
# File 'lib/tennpipes-base/logger.rb', line 444

def initialize(app, uri_root)
  @app = app
  @uri_root = uri_root.sub(/\/$/,"")
end

Instance Method Details

#call(env) ⇒ Object



449
450
451
452
453
454
455
# File 'lib/tennpipes-base/logger.rb', line 449

def call(env)
  env['rack.logger'] = Tennpipes.logger
  began_at = Time.now
  status, header, body = @app.call(env)
  log(env, status, header, began_at) if logger.debug?
  [status, header, body]
end