class Rack::XrkLog::Dispose
Public Class Methods
new(app, app_name)
click to toggle source
Calls superclass method
Rack::XrkLog::Base::new
# File lib/rack/xrk/adapter/dispose.rb, line 7 def initialize(app, app_name) @app_name = app_name super end
Public Instance Methods
formatter(env, body, status, header)
click to toggle source
# File lib/rack/xrk/adapter/dispose.rb, line 12 def formatter(env, body, status, header) @request = Rack::Request.new(env) return if [%r{^/assets/}, %r{favicon.ico}, %r{404}].any?{|path| path.match(@request.path) } client_ip_and_port = "#{@request.ip}:0" server_ip_and_port = "#{env['SERVER_NAME']}:#{env['SERVER_PORT']}" query_string = @request.query_string.blank? ? "" : @request.query_string [ client_ip_and_port, server_ip_and_port, total_runtime, @request.scheme, (query_string.bytesize rescue nil) || 0, (body[0].bytesize() rescue nil) || 0, @request.request_method, @request.path_info, status, query_string, path_parameters(env), "-", (json_with_nil(body[0]) rescue nil) || "-" ].join("|") end
json_with_nil(value)
click to toggle source
# File lib/rack/xrk/adapter/dispose.rb, line 38 def json_with_nil(value) JSON.parse(value).to_json end
path_parameters(env)
click to toggle source
# File lib/rack/xrk/adapter/dispose.rb, line 42 def path_parameters(env) opts = env["action_dispatch.request.path_parameters"] return "#{opts[:controller]}/#{opts[:action]}" unless opts.blank? end