Module: Timber::Overrides::ActiveSupportTaggedLogging::LoggerMethods

Defined in:
lib/timber-rails/overrides/active_support_tagged_logging.rb

Class Method Summary collapse

Class Method Details

.included(klass) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/timber-rails/overrides/active_support_tagged_logging.rb', line 33

def self.included(klass)
  klass.class_eval do
    def add(severity, message = nil, progname = nil, &block)
      if message.nil?
        if block_given?
          message = block.call
        else
          message = progname
          progname = nil #No instance variable for this like Logger
        end
      end
      if @logger.is_a?(Timber::Logger)
        @logger.add(severity, message, progname)
      else
        @logger.add(severity, "#{tags_text}#{message}", progname)
      end
    end
  end
end