Sha256: 67852ab783310b71d26a2511a16aa9ebc84919b602d690f22c3d9b623300d5e3

Contents?: true

Size: 1.31 KB

Versions: 78

Compression:

Stored size: 1.31 KB

Contents

require 'active_support/core_ext/module/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

78 entries across 73 versions & 9 rubygems

Version Path
activesupport-4.1.14.2 lib/active_support/logger.rb
activesupport-4.2.5.2 lib/active_support/logger.rb
activejob-lock-0.0.2 rails/activesupport/lib/active_support/logger.rb
activesupport-4.2.5.1 lib/active_support/logger.rb
activesupport-4.1.14.1 lib/active_support/logger.rb
angular-rails4-templates-0.4.1 vendor/ruby/2.1.0/gems/activesupport-4.1.13/lib/active_support/logger.rb
angular-rails4-templates-0.4.1 vendor/ruby/2.1.0/gems/activesupport-4.2.4/lib/active_support/logger.rb
angular-rails4-templates-0.4.0 vendor/ruby/2.1.0/gems/activesupport-4.2.4/lib/active_support/logger.rb
angular-rails4-templates-0.4.0 vendor/ruby/2.1.0/gems/activesupport-4.1.13/lib/active_support/logger.rb
tdiary-4.2.1 vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.5/lib/active_support/logger.rb
tdiary-4.2.1 vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.5/lib/active_support/logger.rb
angular-rails4-templates-0.3.0 vendor/ruby/2.1.0/gems/activesupport-4.2.4/lib/active_support/logger.rb
angular-rails4-templates-0.3.0 vendor/ruby/2.1.0/gems/activesupport-4.1.13/lib/active_support/logger.rb
activesupport-4.1.14 lib/active_support/logger.rb
activesupport-4.2.5 lib/active_support/logger.rb
activesupport-4.2.5.rc2 lib/active_support/logger.rb
activesupport-4.1.14.rc2 lib/active_support/logger.rb
activesupport-4.2.5.rc1 lib/active_support/logger.rb
activesupport-4.1.14.rc1 lib/active_support/logger.rb
sc_core-0.0.7 test/dummy/vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.4/lib/active_support/logger.rb