I want to modify this logger class which currently lets me log to a file and to the console. (https://objectcomputing.com/resources/publications/sett/may-2016-boostlog-library) However, there are several loops in my program that consecutively print the same error message. I would like to use boost filter or anything else that's compatible with boost log to squash these duplicate messages into one.
I've tried modifying my program to look out for these duplicate messages and only output to the logger if it's not an immediate duplicate but currently it's constrained to a particular loop - I was wondering if I could control this behaviour at the sink.
This is how the messages are passed into the logger:
#define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__)
#define LOG_LOG_LOCATION(LOGGER, LEVEL, ARG)
BOOST_LOG_SEV(LOGGER, boost::log::trivial::LEVEL)
<< boost::log::add_value("Line", __LINE__)
<< boost::log::add_value("File", __FILENAME__)
<< boost::log::add_value("Function", __FUNCTION__) << ARG;
#define LOG_INFO(ARG) LOG_LOG_LOCATION(sysLogger::get(), info, ARG);
...
LOG_INFO("Log Start");
My first step so far was to turn off the auto flush since I'll need to see what messages are on the buffer to identify duplicates. After that, I should inspect the buffer to see whether the previous log message contained the same message and then filter them completely. How do I access this buffer and how do I set the filter to ignore something completely? Should I even be using filters (or boost log for that matter)?
Aucun commentaire:
Enregistrer un commentaire