Sha256: f43e3dc2a66d963ef8d34d5e6db4ee190029c8e2399caf63bff29c72b842e752

Contents?: true

Size: 1.39 KB

Versions: 139

Compression:

Stored size: 1.39 KB

Contents

# :nodoc:
module Log4r
  class Logger
    # Returns the root logger. Identical to Logger.global
    def self.root; return RootLogger.instance end
    # Returns the root logger. Identical to Logger.root
    def self.global; return root end
    
    # Get a logger with a fullname from the repository or nil if logger
    # wasn't found.

    def self.[](_fullname)
      # forces creation of RootLogger if it doesn't exist yet.
      return RootLogger.instance if _fullname=='root' or _fullname=='global'
      Repository[_fullname]
    end

    # Like Logger[] except that it raises NameError if Logger wasn't found.

    def self.get(_fullname)
      logger = self[_fullname]
      if logger.nil?
        raise NameError, "Logger '#{_fullname}' not found.", caller
      end
      logger
    end

    # Yields fullname and logger for every logger in the system.
    def self.each
      for fullname, logger in Repository.instance.loggers
        yield fullname, logger
      end
    end

    def self.each_logger
      Repository.instance.loggers.each_value {|logger| yield logger}
    end

    # Internal logging for Log4r components. Accepts only blocks.
    # To see such log events, create a logger named 'log4r' and give 
    # it an outputter.

    def self.log_internal(level=1)
      internal = Logger['log4r']
      return if internal.nil?
      internal.send(LNAMES[level].downcase, yield)
    end
  end
end

Version data entries

139 entries across 101 versions & 18 rubygems

Version Path
vagrant-unbundled-2.2.19.0 vendor/bundle/ruby/3.0.0/gems/log4r-1.1.10/lib/log4r/staticlogger.rb
vagrant-unbundled-2.2.18.0 vendor/bundle/ruby/3.0.0/gems/log4r-1.1.10/lib/log4r/staticlogger.rb
vagrant-unbundled-2.2.16.0 vendor/bundle/ruby/3.0.0/gems/log4r-1.1.10/lib/log4r/staticlogger.rb
vagrant-unbundled-2.2.16.0 vendor/bundle/ruby/2.7.0/gems/log4r-1.1.10/lib/log4r/staticlogger.rb
vagrant-unbundled-2.2.14.0 vendor/bundle/ruby/2.7.0/gems/log4r-1.1.10/lib/log4r/staticlogger.rb
vagrant-unbundled-2.2.10.0 vendor/bundle/ruby/2.7.0/gems/log4r-1.1.10/lib/log4r/staticlogger.rb
vagrant-unbundled-2.2.9.0 vendor/bundle/ruby/2.7.0/gems/log4r-1.1.10/lib/log4r/staticlogger.rb
vagrant-unbundled-2.2.8.0 vendor/bundle/ruby/2.7.0/gems/log4r-1.1.10/lib/log4r/staticlogger.rb
vagrant-unbundled-2.2.7.0 vendor/bundle/ruby/2.6.0/gems/log4r-1.1.10/lib/log4r/staticlogger.rb
vagrant-unbundled-2.2.7.0 vendor/bundle/ruby/2.7.0/gems/log4r-1.1.10/lib/log4r/staticlogger.rb
vagrant-unbundled-2.2.7.0 vendor/bundle/ruby/2.4.0/gems/log4r-1.1.10/lib/log4r/staticlogger.rb
vagrant-unbundled-2.2.6.2 vendor/bundle/ruby/2.6.0/gems/log4r-1.1.10/lib/log4r/staticlogger.rb
vagrant-unbundled-2.2.6.1 vendor/bundle/ruby/2.6.0/gems/log4r-1.1.10/lib/log4r/staticlogger.rb
vagrant-unbundled-2.2.6.0 vendor/bundle/ruby/2.6.0/gems/log4r-1.1.10/lib/log4r/staticlogger.rb
vagrant-unbundled-2.2.5.0 vendor/bundle/ruby/2.5.0/gems/log4r-1.1.10/lib/log4r/staticlogger.rb
vagrant-unbundled-2.2.5.0 vendor/bundle/ruby/2.6.0/gems/log4r-1.1.10/lib/log4r/staticlogger.rb
vagrant-unbundled-2.2.4.0 vendor/bundle/ruby/2.5.0/gems/log4r-1.1.10/lib/log4r/staticlogger.rb
vagrant-unbundled-2.2.4.0 vendor/bundle/ruby/2.6.0/gems/log4r-1.1.10/lib/log4r/staticlogger.rb
vagrant-unbundled-2.2.3.0 vendor/bundle/ruby/2.5.0/gems/log4r-1.1.10/lib/log4r/staticlogger.rb
vagrant-unbundled-2.2.2.0 vendor/bundle/ruby/2.5.0/gems/log4r-1.1.10/lib/log4r/staticlogger.rb