ChimeraTK-ApplicationCore  04.01.00
ChimeraTK::Logger Class Reference

#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 LoggergetInstance ()
 Obtain global instance of Logger singleton. More...
 

Friends

class Application
 

Detailed Description

Definition at line 15 of file Logger.h.

Member Enumeration Documentation

◆ Severity

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 

Definition at line 27 of file Logger.h.

Constructor & Destructor Documentation

◆ ~Logger()

ChimeraTK::Logger::~Logger ( )

Definition at line 11 of file Logger.cc.

Member Function Documentation

◆ getInstance()

Logger & ChimeraTK::Logger::getInstance ( )
inlinestatic

Obtain global instance of Logger singleton.

Definition at line 131 of file Logger.h.

+ Here is the caller graph for this function:

◆ getStream()

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.

+ Here is the caller graph for this function:

◆ setMinSeverity()

void ChimeraTK::Logger::setMinSeverity ( Severity  minSeverity)
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.

Definition at line 34 of file Logger.h.

Friends And Related Function Documentation

◆ Application

friend class Application
friend

Definition at line 116 of file Logger.h.


The documentation for this class was generated from the following files: