RSC
0.16.0
|
Factory to create logger instances. More...
#include <LoggerFactory.h>
Classes | |
class | ReconfigurationVisitor |
class | ReselectVisitor |
Public Member Functions | |
virtual | ~LoggerFactory () |
LoggerPtr | getLogger (const std::string &name="") |
Get a logger for the given name. More... | |
void | reconfigure (const Logger::Level &level) |
Simple hack to reconfigure all known loggers and new instances with a logging level. More... | |
void | reconfigureFromFile (const std::string &fileName) |
Reconfigures the logging system from a configuration file. More... | |
void | reselectLoggingSystem (const std::string &nameHint="") |
Reselected the automatically chosen logging system to adapt to newly available ones. More... | |
std::string | getLoggingSystemName () |
Returns the name of the currently selected logging system. More... | |
void | clearKnownLoggers () |
Do not use this, for testing only! More... | |
Public Member Functions inherited from rsc::patterns::Singleton< LoggerFactory > | |
virtual | ~Singleton () |
Static Public Attributes | |
static const std::string | DEFAULT_LOGGING_SYSTEM |
Parameter to pass as name hint to reselectLoggingSystem for selecting the default system. More... | |
static const Logger::Level | DEFAULT_LEVEL = Logger::LEVEL_WARN |
Default level when the system is used without prior initialization. More... | |
Private Member Functions | |
LoggerFactory () | |
LoggerProxyPtr | createLogger (const LoggerTreeNode::NamePath &path, LoggerTreeNodePtr node) |
Private Attributes | |
boost::shared_ptr< LoggingSystem > | loggingSystem |
boost::recursive_mutex | mutex |
LoggerTreeNodePtr | loggerTree |
Friends | |
class | patterns::Singleton< LoggerFactory > |
Additional Inherited Members | |
Static Public Member Functions inherited from rsc::patterns::Singleton< LoggerFactory > | |
static LoggerFactory & | getInstance () |
Retrieve the singleton instance, creating it if necessary. More... | |
static void | killInstance () |
This function can be used to make sure the instance is deleted at a particular time. More... | |
Factory to create logger instances.
On singleton creation selects a logger according to the heuristic mentioned for reselectLoggingSystem.
Definition at line 83 of file LoggerFactory.h.
|
private |
Definition at line 118 of file LoggerFactory.cpp.
|
virtual |
Definition at line 137 of file LoggerFactory.cpp.
void rsc::logging::LoggerFactory::clearKnownLoggers | ( | ) |
Do not use this, for testing only!
Definition at line 263 of file LoggerFactory.cpp.
|
private |
Definition at line 203 of file LoggerFactory.cpp.
LoggerPtr rsc::logging::LoggerFactory::getLogger | ( | const std::string & | name = "" | ) |
Get a logger for the given name.
If a logger with this name already exists, the existing instance is returned.
Receiving a logger is a quite expensive operation if a logger with the specified name did not exist before at runtime. Hence, do not use constantly changing names for loggers with a short lifetime.
name | name of the logger, empty string means root logger |
Definition at line 219 of file LoggerFactory.cpp.
string rsc::logging::LoggerFactory::getLoggingSystemName | ( | ) |
Returns the name of the currently selected logging system.
Definition at line 258 of file LoggerFactory.cpp.
void rsc::logging::LoggerFactory::reconfigure | ( | const Logger::Level & | level | ) |
Simple hack to reconfigure all known loggers and new instances with a logging level.
Only loggers which had a manually assigned level will actually be assigned with the new level. All others use the inheritance tree to get a level. Effectively this will result in all loggers appearing with the same level but semantics for changing certain levels in the logger tree are preserved.
level | new level for all loggers |
Definition at line 250 of file LoggerFactory.cpp.
void rsc::logging::LoggerFactory::reconfigureFromFile | ( | const std::string & | fileName | ) |
Reconfigures the logging system from a configuration file.
fileName | name of the configuration file |
std::invalid_argument | invalid file path |
Definition at line 268 of file LoggerFactory.cpp.
References rsc::config::ConfigFileSource::provideOptions().
void rsc::logging::LoggerFactory::reselectLoggingSystem | ( | const std::string & | nameHint = "" | ) |
Reselected the automatically chosen logging system to adapt to newly available ones.
A hint can be given on the name of the logging system to select.
If no hint is given the first found logging system which is not the default will be selected. If no such system exists, the default is used. The name hint overrides these settings if a logging system matching the hint is found.
This method will NOT change previously gathered loggers.
nameHint | hint for the name of the logging system to select. If the string is empty, it will not be used. If it is DEFAULT_LOGGING_SYSTEM, the default logging system will be selected even if other systems are available. |
Definition at line 160 of file LoggerFactory.cpp.
References rsc::logging::loggingSystemRegistry().
|
friend |
Definition at line 89 of file LoggerFactory.h.
|
static |
Default level when the system is used without prior initialization.
Definition at line 154 of file LoggerFactory.h.
|
static |
Parameter to pass as name hint to reselectLoggingSystem for selecting the default system.
Definition at line 149 of file LoggerFactory.h.
|
private |
Definition at line 179 of file LoggerFactory.h.
|
private |
Definition at line 176 of file LoggerFactory.h.
|
private |
Definition at line 178 of file LoggerFactory.h.