Class: U::Log::RackLogger
- Inherits:
-
Rack::CommonLogger
- Object
- Rack::CommonLogger
- U::Log::RackLogger
- Defined in:
- lib/u-log/rack_logger.rb
Class Method Summary collapse
-
.silence_common_logger! ⇒ Object
In development mode the common logger is always inserted.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, logger) ⇒ RackLogger
constructor
A new instance of RackLogger.
Constructor Details
#initialize(app, logger) ⇒ RackLogger
Returns a new instance of RackLogger.
11 12 13 14 |
# File 'lib/u-log/rack_logger.rb', line 11 def initialize(app, logger) @app = app @logger = logger end |
Class Method Details
.silence_common_logger! ⇒ Object
In development mode the common logger is always inserted
6 7 8 9 |
# File 'lib/u-log/rack_logger.rb', line 6 def self.silence_common_logger! Rack::CommonLogger.module_eval('def call(env); @app.call(env); end') self end |
Instance Method Details
#call(env) ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/u-log/rack_logger.rb', line 16 def call(env) began_at = Time.now status, header, body = @app.call(env) header = Rack::Utils::HeaderHash.new(header) body = Rack::BodyProxy.new(body) { log(env, status, header, began_at) } [status, header, body] end |