Class: Logcraft::Rails::RequestLogger
- Inherits:
-
Object
- Object
- Logcraft::Rails::RequestLogger
- Defined in:
- lib/logcraft/rails/request_logger.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, logger, config) ⇒ RequestLogger
constructor
A new instance of RequestLogger.
Constructor Details
#initialize(app, logger, config) ⇒ RequestLogger
Returns a new instance of RequestLogger.
6 7 8 9 10 |
# File 'lib/logcraft/rails/request_logger.rb', line 6 def initialize(app, logger, config) @app = app @logger = logger @config = config end |
Instance Method Details
#call(env) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/logcraft/rails/request_logger.rb', line 12 def call(env) start_time = current_time_in_milliseconds request = ActionDispatch::Request.new env instrumentation_start request status, headers, body = @app.call env body = ::Rack::BodyProxy.new(body) { instrumentation_finish request } log_request request, status, start_time [status, headers, body] rescue Exception => ex instrumentation_finish request log_request request, status_for_error(ex), start_time raise ensure ActiveSupport::LogSubscriber.flush_all! end |