#include <Pt/System/LogTarget.h>
Target of log-messages. More...
Inherits NonCopyable.
Public Member Functions | |
virtual | ~LogTarget () |
Destructor. | |
std::string | channelUrl () const |
Returns the URL of the channel used by the target. | |
void | log (const LogRecord &record) |
Write log record to this target. | |
int | logLevel () const |
Returns the log level of the target. | |
const std::string & | name () const |
Returns the name of the target. | |
void | setChannel (const std::string &url) |
Sets the channel to be used by this target. More... | |
void | setLogLevel (LogLevel level) |
Sets the log-level of the target and its children. More... | |
Static Public Member Functions | |
static LogTarget & | get (const std::string &name) |
Get a target from the logging manager. More... | |
The logging manager singleton maintains a hierachy of log targets, which is used to route the log records to a channel. To add an instance to this hierachy use the static LogTarget::get method. The scheme of the target category name follows the property dot-syntax. If there is a target foobar.ping and a target foobar.pong it means that ping and pong are children of the foobar target, which is a child of the root target.
Targets are not used directly, but by the loggers in an application. Once a target is created, a channel can be assigned to it. If no channel is assigned to a target, it will use the channel of the next of its parent targets. Each target also has a log level which is used by the logger to determine if a record should be sent to a target.
void setLogLevel | ( | LogLevel | level | ) |
This method is thread-safe. The log-level can also be set in the settings file of the used for initialization. All children of this target inherit the given LogLevel unless they are already set to a log level explicitly i.e. this method has een called on a child before.
void setChannel | ( | const std::string & | url | ) |
Throws a invalid_argument exception if the channel can not be created. This function might block until the channel could be opened. This method is thread-safe. The channel can also be set in the properties file of the logging-manager.
|
static |
The target is created if it does not exist, otherwise the existing target is returned. If the target is created it is initialised with the properties from the configuration file of the loggin manager. This method is thread-safe.