Module: Sentry::StdLibLogger
- Defined in:
- lib/sentry/std_lib_logger.rb
Overview
Ruby Logger support Add commentMore actions intercepts any logger instance and send the log to Sentry too.
Constant Summary collapse
- SEVERITY_MAP =
{ 0 => :debug, 1 => :info, 2 => :warn, 3 => :error, 4 => :fatal }.freeze
Instance Method Summary collapse
Instance Method Details
#add(severity, message = nil, progname = nil, &block) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/sentry/std_lib_logger.rb', line 15 def add(severity, = nil, progname = nil, &block) result = super return unless Sentry.initialized? && Sentry.get_current_hub # exclude sentry SDK logs -- to prevent recursive log action, # do not process internal logs again if .nil? && progname != Sentry::Logger::PROGNAME # handle different nature of Ruby Logger class: # inspo from Sentry::Breadcrumb::SentryLogger if block_given? = yield else = progname end = .to_s.strip if !.nil? && != Sentry::Logger::PROGNAME && method = SEVERITY_MAP[severity] Sentry.logger.send(method, ) end end result end |