Class: Napa::Middleware::Logger

Inherits:
Object
  • Object
show all
Defined in:
lib/napa/middleware/logger.rb

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ Logger

Returns a new instance of Logger.



4
5
6
# File 'lib/napa/middleware/logger.rb', line 4

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/napa/middleware/logger.rb', line 8

def call(env)
  # log the request
  Napa::Logger.logger.debug format_request(env)

  # process the request
  status, headers, body = @app.call(env)

  # log the response
  Napa::Logger.logger.debug format_response(status, headers, body)

  # return the results
  [status, headers, body]
ensure
  # Clear the transaction id after each request
  Napa::LogTransaction.clear
end