Class: LogjamAgent::Rack::Logger

Inherits:
ActiveSupport::LogSubscriber
  • Object
show all
Includes:
Obfuscation
Defined in:
lib/logjam_agent/rack/logger.rb

Constant Summary

Constants included from Obfuscation

Obfuscation::KEY_RE, Obfuscation::PAIR_RE, Obfuscation::VAL_RE

Instance Method Summary collapse

Methods included from Obfuscation

#cookie_obfuscator, #filter_pairs, #ip_obfuscator, #obfuscate_cookie

Constructor Details

#initialize(app, taggers = nil) ⇒ Logger

Returns a new instance of Logger.



8
9
10
11
12
13
14
15
16
# File 'lib/logjam_agent/rack/logger.rb', line 8

def initialize(app, taggers = nil)
  @app = app
  @taggers = taggers || (defined?(Rails::Railtie) ? Rails.application.config.log_tags : []) || []
  @hostname = LogjamAgent.hostname
  @asset_prefix = Rails.application.config.assets.prefix rescue "---"
  @ignore_asset_requests = LogjamAgent.ignore_asset_requests
  @ignored_request_urls = LogjamAgent.ignored_request_urls
  @use_to_default_s = Gem::Version.new(ActiveSupport::VERSION::STRING) < Gem::Version.new("7.1.0")
end

Instance Method Details

#call(env) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/logjam_agent/rack/logger.rb', line 18

def call(env)
  if env["logjam_agent.framework"] == :sinatra
    request = ::Sinatra::Request.new(env)
    env["rack.logger"] = logger
  else
    request = ActionDispatch::Request.new(env)
  end

  if logger.respond_to?(:tagged) && !@taggers.empty?
    logger.tagged(compute_tags(request)) { call_app(request, env) }
  else
    call_app(request, env)
  end
end