Belle II Software development
|
The LogMessage class. More...
#include <LogMessage.h>
Classes | |
struct | TextHasher |
Helper struct to hash and compare messages only by log level and message content. More... | |
Public Member Functions | |
LogMessage (LogConfig::ELogLevel logLevel, const std::string &message, const char *package, std::string function, std::string file, unsigned int line, int debugLevel=0) | |
The LogMessage constructor. | |
LogMessage (LogConfig::ELogLevel logLevel, LogVariableStream &&messageStream, const char *package, std::string function, std::string file, unsigned int line, int debugLevel=0) | |
The LogMessage constructor taking a LogVariableStream which can contains name/value pairs. | |
LogMessage (LogMessage &&)=default | |
Provide move constructor. | |
LogMessage (LogMessage const &lm)=default | |
Provide copy-constructor. | |
bool | operator== (const LogMessage &message) const |
Compares two messages. | |
bool | operator!= (const LogMessage &message) const |
Check for inequality. | |
LogMessage & | operator= (const LogMessage &lvs)=default |
Custom assignment-operator, thanks to stringsream's incompetence ... | |
LogConfig::ELogLevel | getLogLevel () const |
Returns the log level of the message. | |
const std::string & | getPackage () const |
Returns the package where the message was sent from. | |
const std::string | getMessage () const |
Returns the message text. | |
void | setModule (const std::string &module) |
Configure which information should be printed. | |
void | setLogInfo (unsigned int logInfo) |
Configure which information should be printed. | |
void | setCount (int count) |
Set the number of occurrences. | |
std::ostream & | print (std::ostream &out) const |
Generate output stream. | |
std::string | toJSON (bool complete) const |
Return a json string for the log message. | |
const std::vector< LogVar > & | getLogVariables () const |
Return a reference to the log variables associated with this message. | |
Private Attributes | |
LogConfig::ELogLevel | m_logLevel |
The log level of the message. | |
LogVariableStream | m_message |
The message stream which should be sent. | |
std::string | m_module |
The module name where the message was sent from. | |
std::string | m_package |
The package name where the message was sent from. | |
std::string | m_function |
The function name where the message was sent from. | |
std::string | m_file |
The file name where the message was sent from. | |
unsigned int | m_line |
The line number in the source code where the message was sent from. | |
int | m_debugLevel |
The debug level for messages with level=c_Debug. | |
unsigned int | m_logInfo |
kind of information to show (ORed combination of LogConfig::ELogInfo flags). | |
int | m_count |
Number of occurrences of the same message. | |
The LogMessage class.
This class encapsulates a logging message.
Definition at line 29 of file LogMessage.h.
LogMessage | ( | LogConfig::ELogLevel | logLevel, |
const std::string & | message, | ||
const char * | package, | ||
std::string | function, | ||
std::string | file, | ||
unsigned int | line, | ||
int | debugLevel = 0 |
||
) |
The LogMessage constructor.
logLevel | The log level of the message (e.g. debug, info, warning, error, fatal). |
message | The message string which should be send. This will be internally converted to a LogVariableStream with the text message and 0 variables. |
package | The package name where the message was sent from (can be NULL) |
function | The function name where the message was sent from. |
file | The file name where the message was sent from. |
line | The line number in the source code where the message was sent from. |
debugLevel | The debug level of the message if the logLevel is c_Debug |
Definition at line 25 of file LogMessage.cc.
LogMessage | ( | LogConfig::ELogLevel | logLevel, |
LogVariableStream && | messageStream, | ||
const char * | package, | ||
std::string | function, | ||
std::string | file, | ||
unsigned int | line, | ||
int | debugLevel = 0 |
||
) |
The LogMessage constructor taking a LogVariableStream which can contains name/value pairs.
logLevel | The log level of the message (e.g. debug, info, warning, error, fatal). |
messageStream | The LogVariableStream which should be send. |
package | The package name where the message was sent from (can be NULL) |
function | The function name where the message was sent from. |
file | The file name where the message was sent from. |
line | The line number in the source code where the message was sent from. |
debugLevel | The debug level of the message if the logLevel is c_Debug |
Definition at line 40 of file LogMessage.cc.
|
inline |
Returns the log level of the message.
Definition at line 91 of file LogMessage.h.
|
inline |
Return a reference to the log variables associated with this message.
Definition at line 136 of file LogMessage.h.
|
inline |
Returns the message text.
Definition at line 105 of file LogMessage.h.
|
inline |
Returns the package where the message was sent from.
Definition at line 98 of file LogMessage.h.
|
inline |
bool operator== | ( | const LogMessage & | message | ) | const |
Compares two messages.
Definition at line 57 of file LogMessage.cc.
std::ostream & print | ( | std::ostream & | out | ) | const |
Generate output stream.
out | The output stream. |
Definition at line 128 of file LogMessage.cc.
|
inline |
|
inline |
Configure which information should be printed.
Definition at line 115 of file LogMessage.h.
|
inline |
Configure which information should be printed.
Definition at line 110 of file LogMessage.h.
std::string toJSON | ( | bool | complete | ) | const |
Return a json string for the log message.
The returned string will be a json object containing the full log message on one line
complete | if true include all fields independent of the logInfo settings |
Definition at line 68 of file LogMessage.cc.
|
private |
Number of occurrences of the same message.
Definition at line 168 of file LogMessage.h.
|
private |
The debug level for messages with level=c_Debug.
Definition at line 165 of file LogMessage.h.
|
private |
The file name where the message was sent from.
Definition at line 163 of file LogMessage.h.
|
private |
The function name where the message was sent from.
Definition at line 162 of file LogMessage.h.
|
private |
The line number in the source code where the message was sent from.
Definition at line 164 of file LogMessage.h.
|
private |
kind of information to show (ORed combination of LogConfig::ELogInfo flags).
Definition at line 167 of file LogMessage.h.
|
private |
The log level of the message.
Definition at line 158 of file LogMessage.h.
|
private |
The message stream which should be sent.
Definition at line 159 of file LogMessage.h.
|
private |
The module name where the message was sent from.
Definition at line 160 of file LogMessage.h.
|
private |
The package name where the message was sent from.
Definition at line 161 of file LogMessage.h.