Class: Rack::RequestLogger
- Inherits:
-
RackLogger
- Object
- RackLogger
- Rack::RequestLogger
- Defined in:
- lib/simple_rack_logger/request_logger.rb
Instance Attribute Summary
Attributes inherited from RackLogger
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, logger, *filters) ⇒ RequestLogger
constructor
A new instance of RequestLogger.
Methods inherited from RackLogger
Constructor Details
#initialize(app, logger, *filters) ⇒ RequestLogger
Returns a new instance of RequestLogger.
6 7 8 |
# File 'lib/simple_rack_logger/request_logger.rb', line 6 def initialize(app, logger, *filters) super end |
Instance Method Details
#call(env) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/simple_rack_logger/request_logger.rb', line 10 def call(env) uuid = unique_identy request = Rack::Request.new(env) block = @filters.select { |filter| filter.respond_to?(:filter) && filter.send(:filter, request) } if block.empty? logger.info("IDENT:|#{uuid}| REQUEST_VALUE:|#{expose(request, env)}|") logger.flush end return_value = @app.call(env) if block.empty? logger.info("IDENT:|#{uuid}| RETURN_VALUE:|#{expose_return(return_value).to_s}|") logger.flush end return_value end |