Sha256: c2903b9cad63c06363d794f69c01f8ecaf56e26dfa0c3c5661c38e139290dfe3

Contents?: true

Size: 779 Bytes

Versions: 1

Compression:

Stored size: 779 Bytes

Contents

require "logger"

module Timber
  module Probes
    class Logger < Probe
      module InstanceMethods
        def self.included(klass)
          klass.class_eval do
            alias_method :_timber_old_add, :add

            def add(level, *args, &block)
              if self == Config.logger
                _timber_old_add(level, *args, &block)
              else
                context = Contexts::Logger.new(level, progname)
                CurrentContext.add(context) do
                  _timber_old_add(level, *args, &block)
                end
              end
            end
          end
        end
      end

      def insert!
        return true if ::Logger.include?(InstanceMethods)
        ::Logger.send(:include, InstanceMethods)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
timberio-1.0.0.beta1 lib/timber/probes/logger.rb