Abstract class which provides the interface used by ms_logging monitor to delegate logging events. More...
#include <ms_logging.hpp>
Public Types | |
enum | LogOutputColumns_e { COL_ASC_TIME = 0x0001 , COL_ISO8601_TIME = 0x0002 , COL_IP_ADDRESS = 0x0004 , COL_MSG_NUM_DEC = 0x0008 , COL_MSG_NUM_HEX = 0x0010 , COL_SEVERITY_NUM = 0x0020 , COL_SEVERITY_TXT = 0x0040 , COL_MSG_SOURCE_TXT = 0x0080 , COL_SRC_FILE = 0x0100 , COL_SRC_LINENUM = 0x0200 , COL_THREAD_ID = 0x0400 , COL_MSG = 0x0800 , COL_TSV = 0x1000 , COL_QUOTES = 0x2000 , COL_HEADERS = 0x4000 , COL_LOGGER_DEFAULTS = COL_ISO8601_TIME | COL_MSG_NUM_HEX | COL_SEVERITY_TXT | COL_MSG_SOURCE_TXT | COL_SRC_FILE | COL_SRC_LINENUM | COL_MSG | COL_HEADERS } |
Logging output columns. More... | |
Public Member Functions | |
ms_logger (const unsigned int colsToOutput=COL_MSG) | |
Constructor. | |
virtual | ~ms_logger () |
Destructor. | |
std::string | formatMessage (ms_loggingmonitor::Level_e eSeverity, ms_loggingmonitor::Source_e eSource, long lMsgId, const std::string &text, const char *srcFileName, const int srcFileLineNum, long lContextId) const |
Returns a string with formatting based on the columns requested to be output. | |
virtual unsigned int | getColsToOutput () const |
Return the value which specifies which columns should be output by the logger. | |
std::string | getHeaderLine () const |
Returns the header line based on the specified column names. | |
virtual void | onLogMessage (ms_loggingmonitor::Level_e eSeverity, ms_loggingmonitor::Source_e eSource, long lMsgId, const std::string &text, const char *srcFileName, const int srcFileLineNum, long lContextId=0)=0 |
Processes and handles the passed logging message. | |
virtual void | setColsToOutput (const unsigned int colsToOutput) |
Set the value to specify which columns should be output by the logger. | |
Abstract class which provides the interface used by ms_logging monitor to delegate logging events.
See also ms_stdout_logger and ms_file_logger which inherit from this class.
See Logging using ms_loggingmonitor for examples on using this class
enum LogOutputColumns_e |
Logging output columns.
These flags determine which columns are output by ms_stdout_logger and ms_file_logger.
The only way to change the order of the columns is to override the onLogMessage() function.
Enums with a [*] in the description are included in COL_LOGGER_DEFAULTS
See Using enumerated values and static const ints in Perl, Java, Python and C#.
Enumerator | |
---|---|
COL_ASC_TIME |
|
COL_ISO8601_TIME |
|
COL_IP_ADDRESS |
|
COL_MSG_NUM_DEC |
|
COL_MSG_NUM_HEX |
|
COL_SEVERITY_NUM |
|
COL_SEVERITY_TXT |
|
COL_MSG_SOURCE_TXT |
|
COL_SRC_FILE |
|
COL_SRC_LINENUM |
|
COL_THREAD_ID |
|
COL_MSG |
|
COL_TSV |
|
COL_QUOTES |
|
COL_HEADERS |
|
COL_LOGGER_DEFAULTS |
|
Constructor.
ms_logger is an abstract class, so this is called from ms_stdout_logger, ms_file_logger and should be called from any other inherited classes.
See Logging using ms_loggingmonitor for examples on using this class
colsToOutput | is formed by bitwise ORing one or more ms_logger::LogOutputColumns_e values |
std::string formatMessage | ( | ms_loggingmonitor::Level_e | eSeverity, |
ms_loggingmonitor::Source_e | eSource, | ||
long | lMsgId, | ||
const std::string & | text, | ||
const char * | srcFileName, | ||
const int | srcFileLineNum, | ||
long | lContextId | ||
) | const |
Returns a string with formatting based on the columns requested to be output.
Called by ms_stdout_logger::onLogMessage and ms_file_logger::onLogMessage to return a formatted string based on the ms_logger::LogOutputColumns_e flags returned by getColsToOutput().
This function can obviously also be called by any custom ms_logger
eSeverity | the severity level of the message |
eSource | the source of the message |
lMsgId | the message id or error code |
text | the message text |
srcFileName | will normally be supplied using __FILE__ |
srcFileLineNum | will normally be supplied using __LINE__ |
lContextId | the contextid of the message (from MDRO) |
|
virtual |
Return the value which specifies which columns should be output by the logger.
The value returned is one or more ms_logger::LogOutputColumns_e values bitwise ORed together. formatMessage uses this value to determine which columns to return.
std::string getHeaderLine | ( | ) | const |
Returns the header line based on the specified column names.
|
virtual |
Set the value to specify which columns should be output by the logger.
formatMessage uses this value to determine which columns to return.
colsToOutput | is formed by bitwise ORing one or more ms_logger::LogOutputColumns_e values |