class FinAppsCore::Logging::ContenTypeFormatter
Constants
- CONTENT_TYPE
Public Instance Methods
response(env)
click to toggle source
# File lib/finapps_core/logging/content_type_formatter.rb 10 def response(env) 11 status = proc { "Status #{env.status}" } 12 public_send(log_level, 'response', &status) 13 14 log_headers('response', env.response_headers) if log_headers?(:response) 15 log_body('response', env[:body]) if env[:body] && log_body?(:response) && loggable?(env) 16 end
Private Instance Methods
loggable?(env)
click to toggle source
# File lib/finapps_core/logging/content_type_formatter.rb 20 def loggable?(env) 21 loggable_types = ['application/json', 'text/plain'] 22 process_response_type?(env, loggable_types) 23 end
process_response_type?(env, content_types)
click to toggle source
# File lib/finapps_core/logging/content_type_formatter.rb 25 def process_response_type?(env, content_types) 26 type = response_type(env) 27 content_types.empty? || content_types.any? do |pattern| 28 pattern.is_a?(Regexp) ? type.match?(pattern) : type == pattern 29 end 30 end
response_type(env)
click to toggle source
# File lib/finapps_core/logging/content_type_formatter.rb 32 def response_type(env) 33 type = env[:response_headers][CONTENT_TYPE].to_s 34 type = type.split(';', 2).first if type.index(';') 35 type 36 end