class Vox::HTTP::Middleware::LogFormatter
@!visibility private
Public Instance Methods
log_request_debug(env, req_id)
click to toggle source
Debug level logging for requests. Displays the request body.
# File lib/vox/http/middleware/log_formatter.rb, line 31 def log_request_debug(env, req_id) debug { "{#{req_id}} [OUT] #{env.body}" } end
log_request_info(env, req_id)
click to toggle source
Info level logging for requests. Logs the HTTP
verb, the url path, query string arguments, and request body size.
# File lib/vox/http/middleware/log_formatter.rb, line 24 def log_request_info(env, req_id) query_string = "?#{env.url.query}" if env.url.query size = env.body.respond_to?(:size) ? env.body.size : env.request_headers['Content-Length'] info { "{#{req_id}} [OUT] #{env.method} #{env.url.path}#{query_string} (#{size || 0})" } end
log_response_debug(_env, resp, req_id)
click to toggle source
Debug level logging for responses. Logs the response body.
# File lib/vox/http/middleware/log_formatter.rb, line 56 def log_response_debug(_env, resp, req_id) debug { "{#{req_id}} [IN] #{resp.body}" } end
log_response_error(env, resp, req_id)
click to toggle source
Error
level logging for responses. Logs status code, url path, and response body.
# File lib/vox/http/middleware/log_formatter.rb, line 46 def log_response_error(env, resp, req_id) error { "{#{req_id}} [IN] #{resp.status} #{env.url.path} #{resp.body}" } end
log_response_info(env, resp, req_id)
click to toggle source
Info level logging for responses. Logs status code, url path, and body size.
# File lib/vox/http/middleware/log_formatter.rb, line 51 def log_response_info(env, resp, req_id) info { "{#{req_id}} [IN] #{resp.status} #{env.url.path} (#{resp.body&.size || 0})" } end
request(env)
click to toggle source
Request processing
# File lib/vox/http/middleware/log_formatter.rb, line 13 def request(env) req_id = env.request.context[:trace] log_request_info(env, req_id) # Debug just logs the response with the response body log_request_debug(env, req_id) if env.request_headers['Content-Type'] == 'application/json' debug { "{#{req_id}} [OUT] #{env.request_headers}" } end
response(env)
click to toggle source
Response processing
# File lib/vox/http/middleware/log_formatter.rb, line 36 def response(env) resp = env.response req_id = env.request.context[:trace] log_response_error(env, resp, req_id) unless resp.success? log_response_info(env, resp, req_id) log_response_debug(env, resp, req_id) unless resp.body.empty? end