Class: Thrifty::HTTP::Server::LogMiddleware
- Inherits:
-
Object
- Object
- Thrifty::HTTP::Server::LogMiddleware
- Defined in:
- lib/thrifty/http_server/log_middleware.rb
Constant Summary collapse
- FORMAT =
%{%s "%s %s%s %s" %d %s %0.4f}
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, name) ⇒ LogMiddleware
constructor
A new instance of LogMiddleware.
Constructor Details
#initialize(app, name) ⇒ LogMiddleware
Returns a new instance of LogMiddleware.
6 7 8 9 |
# File 'lib/thrifty/http_server/log_middleware.rb', line 6 def initialize(app, name) @log = Thrifty.get_logger name @app = app end |
Instance Method Details
#call(env) ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/thrifty/http_server/log_middleware.rb', line 11 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 |