Class: Log4r::RootLogger

Inherits:
Logger
  • Object
show all
Includes:
Singleton
Defined in:
lib/log4r/logger.rb

Overview

RootLogger should be retrieved with Logger.root or Logger.global. It’s supposed to be transparent. – We must guarantee the creation of RootLogger before any other Logger or Outputter gets their logging methods defined. There are two guarantees in the code:

  • Logger#deal_with_inheritance - calls RootLogger.instance when a new Logger is created without a parent. Parents must exist, therefore RootLogger is forced to be created.

  • OutputterFactory.create_methods - Calls Logger.root first. So if an Outputter is created, RootLogger is also created.

When RootLogger is created, it calls Log4r.define_levels(*Log4rConfig::LogLevels). This ensures that the default levels are loaded if no custom ones are.

Instance Attribute Summary

Attributes inherited from Logger

#additive, #fullname, #level, #name, #outputters, #parent, #path, #trace

Instance Method Summary collapse

Methods inherited from Logger

#==, [], each, each_logger, #formatter, get, global, #levels, log_internal, root

Constructor Details

#initializeRootLogger

Returns a new instance of RootLogger.



189
190
191
192
193
194
195
196
# File 'lib/log4r/logger.rb', line 189

def initialize
  Log4r.define_levels(*Log4rConfig::LogLevels) # ensure levels are loaded
  @level = ALL
  @outputters = []
  Repository['root'] = self
  Repository['global'] = self
  LoggerFactory.undefine_methods(self)
end

Instance Method Details

#add(*foo) ⇒ Object

Does nothing



212
# File 'lib/log4r/logger.rb', line 212

def add(*foo); end

#additive=(foo) ⇒ Object

Does nothing



210
# File 'lib/log4r/logger.rb', line 210

def additive=(foo); end

#is_root?Boolean

Returns:

  • (Boolean)


198
# File 'lib/log4r/logger.rb', line 198

def is_root?; true end

#level=(alevel) ⇒ Object

Set the global level. Any loggers defined thereafter will not log below the global level regardless of their levels.



203
# File 'lib/log4r/logger.rb', line 203

def level=(alevel); @level = alevel end

#outputters=(foo) ⇒ Object

Does nothing



206
# File 'lib/log4r/logger.rb', line 206

def outputters=(foo); end

#remove(*foo) ⇒ Object

Does nothing



214
# File 'lib/log4r/logger.rb', line 214

def remove(*foo); end

#trace=(foo) ⇒ Object

Does nothing



208
# File 'lib/log4r/logger.rb', line 208

def trace=(foo); end