Module: ActiveLogger::TaggedLogging

Defined in:
lib/active_logger/tagged_logging.rb

Overview

:nodoc:

Defined Under Namespace

Modules: LocalTagStorage

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.new(logger) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/active_logger/tagged_logging.rb', line 16

def self.new(logger)
  logger = logger.dup

  logger.formatter =
    if logger.formatter
      logger.formatter.dup
    else
      # Ensure we set a default formatter so we aren't extending nil!
      ActiveLogger::Formatters::Default.new
    end

  logger.extend(self)
end

Instance Method Details

#flushObject



43
44
45
46
# File 'lib/active_logger/tagged_logging.rb', line 43

def flush
  clear_tags!
  super if defined?(super)
end

#tagged(*tags) ⇒ Object



32
33
34
35
36
37
38
39
40
41
# File 'lib/active_logger/tagged_logging.rb', line 32

def tagged(*tags)
  if block_given?
    formatter.tagged(*tags) { yield self }
  else
    logger = ActiveLogger::TaggedLogging.new(self)
    logger.formatter.extend LocalTagStorage
    logger.push_tags(*formatter.current_tags, *tags)
    logger
  end
end