Class: Rack::SimpleLogger

Inherits:
Object
  • Object
show all
Defined in:
lib/rack/simple_logger.rb,
lib/rack/simple_logger/version.rb

Constant Summary collapse

VERSION =
"0.0.3"

Instance Method Summary collapse

Constructor Details

#initialize(app, options = {}) ⇒ SimpleLogger

Returns a new instance of SimpleLogger.



11
12
13
14
15
16
# File 'lib/rack/simple_logger.rb', line 11

def initialize(app, options={})
  options[:log] ||= STDOUT
  @logger = LogProxy.new(options[:log])
  @filter = options[:filter] || LogFilter.new
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



18
19
20
21
22
23
# File 'lib/rack/simple_logger.rb', line 18

def call(env)
  began_at = Time.now
  status, header, body = @app.call(env)
  log(@filter.pass(env, status, header, began_at))
  [status, header, body]
end