Concrete class which implements ms_logger and stores log text in memory. 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_buffer_logger (unsigned int colsToOutput=ms_logger::COL_LOGGER_DEFAULTS) | |
Constructor, sets columns to report. | |
virtual | ~ms_buffer_logger () |
Destructor. | |
std::vector< std::string > | flush () |
Clear and return all messages from the buffer. | |
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) |
Format and store the passed message in memory. | |
virtual void | setColsToOutput (const unsigned int colsToOutput) |
Set the value to specify which columns should be output by the logger. | |
Concrete class which implements ms_logger and stores log text in memory.
|
inherited |
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 |
|
ms_buffer_logger | ( | unsigned int | colsToOutput = ms_logger::COL_LOGGER_DEFAULTS | ) |
Constructor, sets columns to report.
ms_logger implementation which stores log messages in memory.
colsToOutput | is used to specify the cols to include in the log and also the format |
std::vector< std::string > flush | ( | ) |
Clear and return all messages from the buffer.
|
inherited |
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) |
|
virtualinherited |
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.
|
inherited |
Returns the header line based on the specified column names.
|
virtual |
Format and store the passed message in memory.
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 |
Implements ms_logger.
|
virtualinherited |
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 |