The following is an example of how to redirect all logging from msparser to a specified file and how to specify the logging level.
{
public:
MyLogger(const std::string & logFile, const unsigned int colsToOutput) : ms_logger(colsToOutput)
{
ofs.open(logFile.c_str());
}
long lMsgId, const std::string &text, long lContextId = 0) {
ofs << "0x" << std::hex << std::setw(4) << std::setfill('0') << lMsgId
<< " " << text << std::endl;
}
private:
std::ofstream ofs;
};
int main()
{
MyLogger logger("C:/tmp/log.txt",
}
Abstract class which provides the interface used by ms_logging monitor to delegate logging events.
Definition: ms_logging.hpp:137
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.
Definition: ms_logging.cpp:281
@ COL_ASC_TIME
[ ] Output the time in the format: "Sat Jan 6 11:35:22 2018"
Definition: ms_logging.hpp:152
@ COL_MSG
[*] Output the formatted message text.
Definition: ms_logging.hpp:163
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.
Monitor class to delegate logging events generated from multiple sources.
Definition: ms_logging.hpp:44
static std::string severityAsText(Level_e eSeverity)
Returns a severity enum value as a text string.
Definition: ms_logging.cpp:212
static matrix_science::ms_loggingmonitor & getDefaultMonitor()
Returns the global ms_loggingmonitor used by msparser.
Definition: ms_logging.cpp:156
virtual int addLogEventsHandler(ms_logger &logger)
Registers the passed ms_logger with the ms_loggingmonitor.
Definition: ms_logging.cpp:56
Level_e
Logging severity levels.
Definition: ms_logging.hpp:51
Source_e
Logging event source.
Definition: ms_logging.hpp:65
static std::string messageSourceAsText(Source_e eSource)
Returns a Source_e enum value as a text string.
Definition: ms_logging.cpp:179