Sha256: de0b524d0cd6614835aeea245c9c067749772ab40080cdd6be203a4ae66999b9

Contents?: true

Size: 800 Bytes

Versions: 4

Compression:

Stored size: 800 Bytes

Contents

# frozen_string_literal: true

module Lumberjack
  # Monkey patch for ActiveSupport::TaggedLogger so it doesn't blow up when
  # a Lumberjack logger is trying to be wrapped. This module will be automatically
  # included in ActiveSupport::TaggedLogger if activesupport is already loaded.
  module TaggedLogging
    class << self
      def included(base)
        base.singleton_class.send(:prepend, ClassMethods)
      end
    end
    
    module ClassMethods
      def new(logger)
        if logger.is_a?(Lumberjack::Logger)
          logger = logger.tagged_logger! unless logger.respond_to?(:tagged)
          logger
        else
          super
        end
      end
    end
  end
end

if defined?(ActiveSupport::TaggedLogging)
  ActiveSupport::TaggedLogging.include(Lumberjack::TaggedLogging)
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
lumberjack-1.2.7 lib/lumberjack/tagged_logging.rb
lumberjack-1.2.6 lib/lumberjack/tagged_logging.rb
lumberjack-1.2.5 lib/lumberjack/tagged_logging.rb
lumberjack-1.2.4 lib/lumberjack/tagged_logging.rb