Class: Log4r::RootLogger
- Includes:
- Singleton
- Defined in:
- lib/log4r-color/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, get, global, #levels, log_internal, root
Constructor Details
#initialize ⇒ RootLogger
Returns a new instance of RootLogger.
172 173 174 175 176 177 178 179 |
# File 'lib/log4r-color/logger.rb', line 172 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
195 |
# File 'lib/log4r-color/logger.rb', line 195 def add(*foo); end |
#additive=(foo) ⇒ Object
Does nothing
193 |
# File 'lib/log4r-color/logger.rb', line 193 def additive=(foo); end |
#is_root? ⇒ Boolean
181 |
# File 'lib/log4r-color/logger.rb', line 181 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.
186 |
# File 'lib/log4r-color/logger.rb', line 186 def level=(alevel); @level = alevel end |
#outputters=(foo) ⇒ Object
Does nothing
189 |
# File 'lib/log4r-color/logger.rb', line 189 def outputters=(foo); end |
#remove(*foo) ⇒ Object
Does nothing
197 |
# File 'lib/log4r-color/logger.rb', line 197 def remove(*foo); end |
#trace=(foo) ⇒ Object
Does nothing
191 |
# File 'lib/log4r-color/logger.rb', line 191 def trace=(foo); end |