Module: Datadog::Tracing::Contrib::Lograge::Patcher

Includes:
Patcher
Defined in:
lib/datadog/tracing/contrib/lograge/patcher.rb

Overview

Patcher enables patching of ‘lograge’ module.

Class Method Summary collapse

Methods included from Patcher

included

Class Method Details

.patchObject

patch applies our patch



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/datadog/tracing/contrib/lograge/patcher.rb', line 22

def patch
  # ActiveSupport::TaggedLogging is the default Rails logger since Rails 5
  if defined?(::ActiveSupport::TaggedLogging::Formatter) &&
      ::Lograge::LogSubscribers::ActionController
          .logger&.formatter.is_a?(::ActiveSupport::TaggedLogging::Formatter)
    Datadog.logger.warn(
      'Lograge and ActiveSupport::TaggedLogging (the default Rails log formatter) are not compatible: ' \
        'Lograge does not account for Rails log tags, creating polluted logs and breaking log formatting. ' \
        'Traces and Logs correlation may not work. ' \
        'Either: 1. Disable tagged logging in your Rails configuration ' \
        '`config.logger = ActiveSupport::Logger.new(STDOUT); ' \
        'config.active_job.logger = ActiveSupport::Logger.new(STDOUT)` ' \
        'or 2. Use the `semantic_logger` gem instead of `lograge`.'
    )
  end

  ::Lograge::LogSubscribers::Base.include(Instrumentation)
end

.target_versionObject



17
18
19
# File 'lib/datadog/tracing/contrib/lograge/patcher.rb', line 17

def target_version
  Integration.version
end