Class: Log4r::RootLogger
- 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
-
#add(*foo) ⇒ Object
Does nothing.
-
#additive=(foo) ⇒ Object
Does nothing.
-
#initialize ⇒ RootLogger
constructor
A new instance of RootLogger.
- #is_root? ⇒ Boolean
-
#level=(alevel) ⇒ Object
Set the global level.
-
#outputters=(foo) ⇒ Object
Does nothing.
-
#remove(*foo) ⇒ Object
Does nothing.
-
#trace=(foo) ⇒ Object
Does nothing.
Methods inherited from Logger
#==, [], each, each_logger, #formatter, get, global, #levels, log_internal, root
Constructor Details
#initialize ⇒ RootLogger
Returns a new instance of RootLogger.
179 180 181 182 183 184 185 186 |
# File 'lib/log4r/logger.rb', line 179 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
202 |
# File 'lib/log4r/logger.rb', line 202 def add(*foo); end |
#additive=(foo) ⇒ Object
Does nothing
200 |
# File 'lib/log4r/logger.rb', line 200 def additive=(foo); end |
#is_root? ⇒ Boolean
188 |
# File 'lib/log4r/logger.rb', line 188 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.
193 |
# File 'lib/log4r/logger.rb', line 193 def level=(alevel); @level = alevel end |
#outputters=(foo) ⇒ Object
Does nothing
196 |
# File 'lib/log4r/logger.rb', line 196 def outputters=(foo); end |
#remove(*foo) ⇒ Object
Does nothing
204 |
# File 'lib/log4r/logger.rb', line 204 def remove(*foo); end |
#trace=(foo) ⇒ Object
Does nothing
198 |
# File 'lib/log4r/logger.rb', line 198 def trace=(foo); end |