Sha256: 57be37f580ed02cf1c935240e1ce30797b016d06adeafff618e31db6b1253da4

Contents?: true

Size: 1.04 KB

Versions: 72

Compression:

Stored size: 1.04 KB

Contents

require 'logger'

module Datadog
  LOG_PREFIX = 'ddtrace'.freeze

  # A custom logger with minor enhancements:
  # - progname defaults to ddtrace to clearly identify Datadog dd-trace-rb related messages
  # - adds last caller stack-trace info to know where the message comes from
  class Logger < ::Logger
    def initialize(*args, &block)
      super
      self.progname = LOG_PREFIX
    end

    def add(severity, message = nil, progname = nil, &block)
      where = ''

      # We are in debug mode, or this is an error, add stack trace to help debugging
      if debug? || severity >= ::Logger::ERROR
        c = caller
        where = "(#{c[1]}) " if c.length > 1
      end

      if message.nil?
        if block_given?
          super(severity, message, progname) do
            "[#{self.progname}] #{where}#{yield}"
          end
        else
          super(severity, message, "[#{self.progname}] #{where}#{progname}")
        end
      else
        super(severity, "[#{self.progname}] #{where}#{message}")
      end
    end

    alias log add
  end
end

Version data entries

72 entries across 72 versions & 3 rubygems

Version Path
ls-trace-0.1.2 lib/ddtrace/logger.rb
ddtrace-0.30.1 lib/ddtrace/logger.rb
ddtrace-0.30.0 lib/ddtrace/logger.rb
ddtrace-0.29.1 lib/ddtrace/logger.rb
ddtrace-0.26.1 lib/ddtrace/logger.rb
ls-trace-0.1.1 lib/ddtrace/logger.rb
ddtrace-0.29.0 lib/ddtrace/logger.rb
ddtrace-0.28.0 lib/ddtrace/logger.rb
ddtrace-0.27.0 lib/ddtrace/logger.rb
ddtrace-0.26.0 lib/ddtrace/logger.rb
ddtrace-0.25.1 lib/ddtrace/logger.rb
ddtrace-0.25.0 lib/ddtrace/logger.rb
ddtrace-0.24.0 lib/ddtrace/logger.rb
ddtrace-0.23.3 lib/ddtrace/logger.rb
ddtrace-0.23.2 lib/ddtrace/logger.rb
ddtrace-0.23.1 lib/ddtrace/logger.rb
ddtrace-0.23.0 lib/ddtrace/logger.rb
ddtrace-0.22.0 lib/ddtrace/logger.rb
ddtrace-0.21.2 lib/ddtrace/logger.rb
ddtrace-0.21.1 lib/ddtrace/logger.rb