lib/kiev/rack/request_logger.rb in kiev-4.2.0 vs lib/kiev/rack/request_logger.rb in kiev-4.3.0

- old
+ new

@@ -6,10 +6,11 @@ module Rack class RequestLogger ERROR_STATUS = 500 ERROR_HEADERS = [].freeze ERROR_BODY = [""].freeze + LOG_ERROR = "ERROR" def initialize(app) @app = app end @@ -94,10 +95,12 @@ status: status, request_duration: ((Time.now.to_f - began_at) * 1000).round(3), route: extract_route(env) } + data[:level] = LOG_ERROR if data[:status].to_i.between?(400, 599) + if env[HTTP_X_REQUEST_START] data[:request_latency] = ((began_at - env[HTTP_X_REQUEST_START].to_f) * 1000).round(3) end if config.log_request_body_condition.call(request, response) @@ -131,9 +134,10 @@ should_log_errors = config.log_request_error_condition.call(request, response) if should_log_errors && exception.is_a?(Exception) data[:error_class] = exception.class.name data[:error_message] = exception.message[0..5000] data[:error_backtrace] = Array(exception.backtrace).join(NEW_LINE)[0..5000] + data[:level] = LOG_ERROR end data end def extract_route(env)