Class | Logging::Repository |
In: |
lib/logging/repository.rb
|
Parent: | Object |
The Repository is a hash that stores references to all Loggers that have been created. It provides methods to determine parent/child relationships between Loggers and to retrieve Loggers from the hash.
Returns the Logger named name.
When name is a String or a Symbol it will be used "as is" to retrieve the logger. When name is a Class the class name will be used to retrieve the logger. When name is an object the name of the object‘s class will be used to retrieve the logger.
Example:
repo = Repository.instance obj = MyClass.new log1 = repo[obj] log2 = repo[MyClass] log3 = repo['MyClass'] log1.object_id == log2.object_id # => true log2.object_id == log3.object_id # => true
Stores the logger under the given name.
When name is a String or a Symbol it will be used "as is" to store the logger. When name is a Class the class name will be used to store the logger. When name is an object the name of the object‘s class will be used to store the logger.
Add the given logger names to the list of consolidation masters. All classes in the given namespace(s) will use these loggers instead of creating their own individual loggers.
Returns an array of the children loggers for the logger identified by key where key follows the same identification rules described in +Repository#[]+. Children are returned regardless of the existence of the logger referenced by key.
Returns the Logger named name. An IndexError will be raised if the logger does not exist.
When name is a String or a Symbol it will be used "as is" to retrieve the logger. When name is a Class the class name will be used to retrieve the logger. When name is an object the name of the object‘s class will be used to retrieve the logger.
Returns true if the given logger exists in the repository. Returns false if this is not the case.
When name is a String or a Symbol it will be used "as is" to retrieve the logger. When name is a Class the class name will be used to retrieve the logger. When name is an object the name of the object‘s class will be used to retrieve the logger.
Returns the consolidation master name for the given key. If there is no consolidation master, then nil is returned.
Returns the parent logger for the logger identified by key where key follows the same identification rules described in Repository#[]. A parent is returned regardless of the existence of the logger referenced by key.
A note about parents -
If you have a class A::B::C, then the parent of C is B, and the parent of B is A. Parents are determined by namespace.
Returns the name of the parent for the logger identified by the given key. If the key is for the root logger, then nil is returned.
Takes the given key and converts it into a form that can be used to retrieve a logger from the Repository hash.
When key is a String or a Symbol it will be returned "as is". When key is a Class the class name will be returned. When key is an object the name of the object‘s class will be returned.