@@ -290,6 +290,9 @@ class InfoLogger::Impl
290290 int pipeStderr[2 ]; // a pipe to redirect stderr to collecting thread
291291 std::unique_ptr<std::thread> redirectThread; // the thread handling the redirection
292292 bool redirectThreadShutdown; // flag to ask the thread to stop
293+
294+ bool filterDiscardDebug = false ; // when set, messages with debug severity are dropped
295+ int filterDiscardLevel = InfoLogger::undefinedMessageOption.level; // when set, messages with higher level (>=) are dropped
293296};
294297
295298void InfoLogger::Impl::refreshDefaultMsg ()
@@ -352,6 +355,16 @@ int InfoLogger::Impl::pushMessage(InfoLogger::Severity severity, const char* mes
352355
353356int InfoLogger::Impl::pushMessage (const InfoLoggerMessageOption& options, const InfoLoggerContext& context, const char * messageBody)
354357{
358+ // check if message passes local filter criteria, if any
359+ if (filterDiscardDebug && (options.severity == InfoLogger::Severity::Debug)) {
360+ return 1 ;
361+ }
362+ if ((filterDiscardLevel != undefinedMessageOption.level )
363+ && (options.level != undefinedMessageOption.level )
364+ && (options.level >= filterDiscardLevel)) {
365+ return 1 ;
366+ }
367+
355368 infoLog_msg_t msg = defaultMsg;
356369
357370 struct timeval tv;
@@ -839,6 +852,21 @@ int InfoLogger::setStandardRedirection(bool state)
839852 return 0 ;
840853}
841854
855+ void InfoLogger::filterDiscardDebug (bool enable) {
856+ mPimpl ->filterDiscardDebug =enable;
857+ }
858+
859+ void InfoLogger::filterDiscardLevel (int excludeLevel) {
860+ mPimpl ->filterDiscardLevel = excludeLevel;
861+ }
862+
863+ void InfoLogger::filterReset () {
864+ mPimpl ->filterDiscardDebug = false ;
865+ mPimpl ->filterDiscardLevel = InfoLogger::undefinedMessageOption.level ;
866+ }
867+
868+
869+
842870// end of namespace
843871} // namespace InfoLogger
844872} // namespace AliceO2
0 commit comments