Sha256: d5d073f24295abedcbb8254c07605ae4db4f7b2ac1cd00bdde880709df24ab11

Contents?: true

Size: 1.54 KB

Versions: 51

Compression:

Stored size: 1.54 KB

Contents

module Logging

  # The root logger exists to ensure that all loggers have a parent and a
  # defined logging level. If a logger is additive, eventually its log
  # events will propogate up to the root logger.
  #
  class RootLogger < Logger

    # undefine the methods that the root logger does not need
    %w(additive additive= parent parent=).each do |m|
      undef_method m.intern
    end

    attr_reader :level

    # call-seq:
    #    RootLogger.new
    #
    # Returns a new root logger instance. This method will be called only
    # once when the +Repository+ singleton instance is created.
    #
    def initialize( )
      ::Logging.init unless ::Logging.const_defined? 'MAX_LEVEL_LENGTH'

      @name = 'root'
      @appenders = []
      @additive = false
      @trace = false
      @level = 0
      ::Logging::Logger.define_log_methods(self)
    end

    # call-seq:
    #    log <=> other
    #
    # Compares this logger by name to another logger. The normal return codes
    # for +String+ objects apply.
    #
    def <=>( other )
      case other
      when self; 0
      when ::Logging::Logger; -1
      else raise ArgumentError, 'expecting a Logger instance' end
    end

    # call-seq:
    #    level = :all
    #
    # Set the level for the root logger. The functionality of this method is
    # the same as +Logger#level=+, but setting the level to +nil+ for the
    # root logger is not allowed. The level is silently set to :all.
    #
    def level=( level )
      super(level || 0)
    end

  end  # class RootLogger
end  # module Logging

# EOF

Version data entries

51 entries across 51 versions & 7 rubygems

Version Path
TwP-logging-0.9.7 lib/logging/root_logger.rb
TwP-logging-0.9.8.1 lib/logging/root_logger.rb
TwP-logging-0.9.8.2 lib/logging/root_logger.rb
TwP-logging-0.9.8 lib/logging/root_logger.rb
TwP-logging-1.0.0 lib/logging/root_logger.rb
TwP-logging-1.1.0 lib/logging/root_logger.rb
TwP-logging-1.1.1 lib/logging/root_logger.rb
TwP-logging-1.1.2 lib/logging/root_logger.rb
TwP-logging-1.1.3 lib/logging/root_logger.rb
TwP-logging-1.1.4 lib/logging/root_logger.rb
TwP-logging-1.2.0 lib/logging/root_logger.rb
TwP-logging-1.2.2 lib/logging/root_logger.rb
ottobar-logging-0.9.5.1 lib/logging/root_logger.rb
pjstadig-logging-1.1.4.1 lib/logging/root_logger.rb
logging-1.6.1 lib/logging/root_logger.rb
logging-1.6.0 lib/logging/root_logger.rb
logging-1.5.2 lib/logging/root_logger.rb
logging-1.5.1 lib/logging/root_logger.rb
logging-1.5.0 lib/logging/root_logger.rb
logging-1.4.3 lib/logging/root_logger.rb