Sha256: 369ea00951cdbcad57f4b13be5dcaf064c5d1446ebb8913f4747048e43afeb12

Contents?: true

Size: 1.31 KB

Versions: 30

Compression:

Stored size: 1.31 KB

Contents

require 'active_support/core_ext/class/attribute_accessors'
require 'active_support/logger_silence'
require 'logger'

module ActiveSupport
  class Logger < ::Logger
    include LoggerSilence

    # Broadcasts logs to multiple loggers.
    def self.broadcast(logger) # :nodoc:
      Module.new do
        define_method(:add) do |*args, &block|
          logger.add(*args, &block)
          super(*args, &block)
        end

        define_method(:<<) do |x|
          logger << x
          super(x)
        end

        define_method(:close) do
          logger.close
          super()
        end

        define_method(:progname=) do |name|
          logger.progname = name
          super(name)
        end

        define_method(:formatter=) do |formatter|
          logger.formatter = formatter
          super(formatter)
        end

        define_method(:level=) do |level|
          logger.level = level
          super(level)
        end
      end
    end

    def initialize(*args)
      super
      @formatter = SimpleFormatter.new
    end

    # Simple formatter which only displays the message.
    class SimpleFormatter < ::Logger::Formatter
      # This method is invoked when a log event occurs
      def call(severity, timestamp, progname, msg)
        "#{String === msg ? msg : msg.inspect}\n"
      end
    end
  end
end

Version data entries

30 entries across 30 versions & 2 rubygems

Version Path
activesupport-4.0.13 lib/active_support/logger.rb
activesupport-4.0.13.rc1 lib/active_support/logger.rb
activesupport-4.0.11.1 lib/active_support/logger.rb
activesupport-4.0.12 lib/active_support/logger.rb
activesupport-4.0.11 lib/active_support/logger.rb
activesupport-4.0.10 lib/active_support/logger.rb
activesupport-4.0.10.rc2 lib/active_support/logger.rb
activesupport-4.0.10.rc1 lib/active_support/logger.rb
activesupport-4.0.9 lib/active_support/logger.rb
activesupport-4.0.8 lib/active_support/logger.rb
activesupport-4.0.7 lib/active_support/logger.rb
activesupport-4.0.6 lib/active_support/logger.rb
activesupport-4.0.6.rc3 lib/active_support/logger.rb
activesupport-4.0.6.rc2 lib/active_support/logger.rb
activesupport-4.0.6.rc1 lib/active_support/logger.rb
activesupport-4.0.5 lib/active_support/logger.rb
activesupport-4.0.4 lib/active_support/logger.rb
activesupport-4.0.4.rc1 lib/active_support/logger.rb
activesupport-4.0.3 lib/active_support/logger.rb
activesupport-4.0.2 lib/active_support/logger.rb