Class: YesRackLogger

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

Class Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ YesRackLogger

Returns a new instance of YesRackLogger.



8
9
10
11
# File 'lib/yes_rack_logger.rb', line 8

def initialize(app)
  @app = app
  @logger = self.class.logger
end

Class Attribute Details

.loggerObject

Returns the value of attribute logger.



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

def logger
  @logger
end

Instance Method Details

#call(env) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/yes_rack_logger.rb', line 13

def call(env)
  log_request(env)

  start_allocations = GC.stat[:total_allocated_objects]
  response = @app.call(env)
  allocations = GC.stat[:total_allocated_objects] - start_allocations

  log_response(env, response, allocations)

  response
end