Class: Deas::VerboseLogging
- Inherits:
-
BaseLogging
- Object
- BaseLogging
- Deas::VerboseLogging
- Defined in:
- lib/deas/logging.rb
Constant Summary collapse
- RESPONSE_STATUS_NAMES =
{ 200 => 'OK', 302 => 'FOUND', 400 => 'BAD REQUEST', 401 => 'UNAUTHORIZED', 403 => 'FORBIDDEN', 404 => 'NOT FOUND', 408 => 'TIMEOUT', 500 => 'ERROR' }
Instance Method Summary collapse
-
#call!(env) ⇒ Object
This the real Rack call interface.
- #response_display(status) ⇒ Object
Methods inherited from BaseLogging
#call, #initialize, #log, #log_error
Constructor Details
This class inherits a constructor from Deas::BaseLogging
Instance Method Details
#call!(env) ⇒ Object
This the real Rack call interface. It adds logging before and after super-ing to the common logging behavior.
74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/deas/logging.rb', line 74 def call!(env) log "===== Received request =====" Rack::Request.new(env).tap do |request| log " Method: #{request.request_method.inspect}" log " Path: #{request.path.inspect}" end env['deas.logging'] = Proc.new{ |msg| log(msg) } status, headers, body = super(env) log " Redir: #{headers['Location']}" if headers.key?('Location') log "===== Completed in #{env['deas.time_taken']}ms (#{response_display(status)}) =====" [status, headers, body] end |
#response_display(status) ⇒ Object
87 88 89 |
# File 'lib/deas/logging.rb', line 87 def response_display(status) [status, RESPONSE_STATUS_NAMES[status.to_i]].compact.join(', ') end |