Class: Datadog::Core::Logger
- Inherits:
-
Logger
- Object
- Logger
- Datadog::Core::Logger
- Defined in:
- lib/datadog/core/logger.rb
Overview
A custom logger with minor enhancements:
-
progname defaults to datadog to clearly identify Datadog dd-trace-rb related messages
-
adds last caller stack-trace info to know where the message comes from
Constant Summary collapse
- PREFIX =
'datadog'
Instance Method Summary collapse
- #add(severity, message = nil, progname = nil, &block) ⇒ Object (also: #log)
-
#initialize(*args, &block) ⇒ Logger
constructor
A new instance of Logger.
Constructor Details
Instance Method Details
#add(severity, message = nil, progname = nil, &block) ⇒ Object Also known as: log
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/datadog/core/logger.rb', line 20 def add(severity, = 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 .nil? if block super(severity, , progname) do "[#{self.progname}] #{where}#{yield}" end else super(severity, , "[#{self.progname}] #{where}#{progname}") end else super(severity, "[#{self.progname}] #{where}#{}") end end |