Sha256: 9f6b6f705e0103541ba6c8a35e4d2af35c4b97c9b710f6233966c41711fbc9b4
Contents?: true
Size: 1.2 KB
Versions: 3
Compression:
Stored size: 1.2 KB
Contents
module Jersey::Middleware # Logs request info using the configured logger or the Jersey singleton # # Adds request_id to the default logger params class RequestLogger def initialize(app, options={}) @app = app @logger = options[:logger] || Jersey.logger end def call(env) @request_start = Time.now request = Rack::Request.new(env) start_data = { at: "start", request_id: env['REQUEST_ID'], method: request.request_method, path: request.path_info, content_type: request.content_type, content_length: request.content_length } @logger.log(start_data) status, headers, response = @app.call(env) @logger.log( at: "finish", method: request.request_method, path: request.path_info, status: status, content_length: headers['Content-Length'], route_signature: env['ROUTE_SIGNATURE'], elapsed: (Time.now - @request_start).to_f, request_id: env['REQUEST_ID'] ) @logger.reset!(:request_id) [status, headers, response] end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
jersey-0.2.0 | lib/jersey/middleware/request_logger.rb |
jersey-0.1.0 | lib/jersey/middleware/request_logger.rb |
jersey-0.0.3 | lib/jersey/middleware/request_logger.rb |