Class: LoggerWare::Rack
- Inherits:
-
Object
- Object
- LoggerWare::Rack
- Includes:
- Collector
- Defined in:
- lib/logger_ware/rack.rb
Constant Summary
Constants included from Collector
Collector::COLLECT_PARAMS, Collector::FILTER_PARAMS, Collector::PARAM_FILTERS
Constants included from Filter
Class Attribute Summary collapse
-
.collect_params ⇒ Object
Returns the value of attribute collect_params.
-
.error_handler ⇒ Object
Returns the value of attribute error_handler.
-
.filter_params ⇒ Object
Returns the value of attribute filter_params.
-
.filters ⇒ Object
Returns the value of attribute filters.
-
.handler ⇒ Object
Returns the value of attribute handler.
-
.replace_with ⇒ Object
Returns the value of attribute replace_with.
Instance Method Summary collapse
- #call(env) ⇒ Object
- #data(env) ⇒ Object
- #duration(started_at) ⇒ Object
-
#initialize(app) ⇒ Rack
constructor
A new instance of Rack.
Methods included from Collector
Methods included from Filter
Constructor Details
#initialize(app) ⇒ Rack
Returns a new instance of Rack.
23 24 25 |
# File 'lib/logger_ware/rack.rb', line 23 def initialize(app) @app = app end |
Class Attribute Details
.collect_params ⇒ Object
Returns the value of attribute collect_params.
16 17 18 |
# File 'lib/logger_ware/rack.rb', line 16 def collect_params @collect_params end |
.error_handler ⇒ Object
Returns the value of attribute error_handler.
16 17 18 |
# File 'lib/logger_ware/rack.rb', line 16 def error_handler @error_handler end |
.filter_params ⇒ Object
Returns the value of attribute filter_params.
16 17 18 |
# File 'lib/logger_ware/rack.rb', line 16 def filter_params @filter_params end |
.filters ⇒ Object
Returns the value of attribute filters.
16 17 18 |
# File 'lib/logger_ware/rack.rb', line 16 def filters @filters end |
.handler ⇒ Object
Returns the value of attribute handler.
16 17 18 |
# File 'lib/logger_ware/rack.rb', line 16 def handler @handler end |
.replace_with ⇒ Object
Returns the value of attribute replace_with.
16 17 18 |
# File 'lib/logger_ware/rack.rb', line 16 def replace_with @replace_with end |
Instance Method Details
#call(env) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/logger_ware/rack.rb', line 27 def call(env) started_at = Time.now.utc status, headers, response = @app.call(env) handler[{status: status, headers: headers, response: response, started_at: started_at, duration: duration(started_at), data: data(env)}] [status, headers, response] rescue => exception error_handler[{exception: exception, started_at: started_at, duration: duration(started_at), data: data(env)}] raise exception end |
#data(env) ⇒ Object
41 42 43 |
# File 'lib/logger_ware/rack.rb', line 41 def data(env) collect(env, collect_params, filter_params, filters, replace_with) end |
#duration(started_at) ⇒ Object
45 46 47 |
# File 'lib/logger_ware/rack.rb', line 45 def duration(started_at) Time.now.utc - started_at end |