Sha256: 75da590a5011e135b515b19fb47b904d39e3624d7c6d431d7f11dfac14f96f9b
Contents?: true
Size: 1.07 KB
Versions: 5
Compression:
Stored size: 1.07 KB
Contents
# typed: true require 'logger' module Datadog # 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 PREFIX = 'ddtrace'.freeze def initialize(*args, &block) super self.progname = PREFIX self.level = ::Logger::INFO 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 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
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
ddtrace-0.54.2 | lib/ddtrace/logger.rb |
ddtrace-0.54.1 | lib/ddtrace/logger.rb |
ddtrace-0.54.0 | lib/ddtrace/logger.rb |
ddtrace-0.53.0 | lib/ddtrace/logger.rb |
ddtrace-0.52.0 | lib/ddtrace/logger.rb |