ChimeraTK-ApplicationCore
04.01.00
|
#include <Logger.h>
Classes | |
class | StreamProxy |
Proxy for output stream, handed out to the log sources by the Logger::Module. More... | |
Public Types | |
enum | Severity { Severity::trace, Severity::debug, Severity::info, Severity::warning, Severity::error } |
Severity levels used by the Logger. More... | |
Public Member Functions | |
void | setMinSeverity (Severity minSeverity) |
Set the minimum severity level to be passed to the logger. More... | |
StreamProxy | getStream (Severity severity, std::string context) |
Return an output stream object for the given severity. More... | |
~Logger () | |
Static Public Member Functions | |
static Logger & | getInstance () |
Obtain global instance of Logger singleton. More... | |
Friends | |
class | Application |
|
strong |
Severity levels used by the Logger.
Note: there is no "fatal" severity, since the logger system does not work if the application is terminated immediately after sending a message to the log. Fatal errors shall be printed directly to std::cerr before terminating the application.
Enumerator | |
---|---|
trace | |
debug | |
info | |
warning | |
error |
|
inlinestatic |
Logger::StreamProxy ChimeraTK::Logger::getStream | ( | Logger::Severity | severity, |
std::string | context | ||
) |
Return an output stream object for the given severity.
Writing to the stream object will compose the log message locally, if the given severity is above the configured minimum severity (cf. setMinSeverity()). When the stream object is destroyed (i.e. as it goes out of scope) the message will be sent to the logging thread for further processing. The stream object shall not live long, typically each log line will use its own stream object, unless multiple lines shall be sent and printed consistently, in which case "\n" or std::endl can be written to the stream. It is not necessary to terminate the line ("\n" or std::endl) manually before destrying the stream object, since the
If the given severity is below the minimum severity, the stream will be in a failed state and hence writing to the stream will be a no-op (like std::ostream constructed from a nullptr). If data written to the stream is expensive to obtain, it is recommended to check StreamProxy::good() before computing the data.
The given context string will be used to identify the source of the log information.
Note: Consider using the convenience function ChimeraTK::logger() instead of calling this member function directly.
Definition at line 43 of file Logger.cc.
|
inline |
Set the minimum severity level to be passed to the logger.
By default, the minimum severity is set to Severity::info, so that trace and debug messages will not be processed. This will also prevent (to a certain extend) that the message text is composed at sender-side, which improves performance.
|
friend |