Sha256: 277cef3a6176c6428bef333616fa4ecdd0af5eddb84956e0e55de69c316352e9
Contents?: true
Size: 1.31 KB
Versions: 3
Compression:
Stored size: 1.31 KB
Contents
module Timber module Integrations module Rack # Reponsible for capturing and logging HTTP server requests and response events. class HTTPEvents def initialize(app) @app = app end def call(env) start = Time.now request = Util::Request.new(env) body = Config.instance.capture_http_bodies? ? request.body_content : nil Config.instance.logger.info do Events::HTTPServerRequest.new( body: body, headers: request.headers, host: request.host, method: request.request_method, path: request.path, port: request.port, query_string: request.query_string, request_id: request.request_id, # we insert this middleware after ActionDispatch::RequestId scheme: request.scheme ) end status, headers, body = @app.call(env) Config.instance.logger.info do time_ms = (Time.now - start) * 1000.0 Events::HTTPServerResponse.new( headers: headers, request_id: request.request_id, status: status, time_ms: time_ms ) end [status, headers, body] end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
timber-2.0.2 | lib/timber/integrations/rack/http_events.rb |
timber-2.0.1 | lib/timber/integrations/rack/http_events.rb |
timber-2.0.0 | lib/timber/integrations/rack/http_events.rb |