1

I am in the process of selecting a logging system for our software development. We are using Boost extensively so the obvious option is boost.log V2

but before I select it to be used in my team, I have some questions that I could not find the answer in the documentation:

1- Can I remove the effect of it completely from the generated code? For example assume that I have this code and I need it to be in this way for debugging:

 int main()
{
     for( int i=0;i<100;i++)
     {
         int j=doSomething(i);
         BOOST_LOG_TRIVIAL(trace) << << "I=2<<i <<" j="<<j;
      }
}

is there any way that I remove the effect of logging system in above code so I am not loosing any performance as the result of using it?

2- Can I add section to the logging at the same time that I am adding severity? My code has several sections and we are working on a section at any time. I want to be able to set the logging to log the data for a specific section and not for the whole application which may have several section and possibly hundred of logging entry which needs to be filtered based on the part that I am working on it.

3- possibility of sending different logging to different sinks so for example some logging goes to console and some other goes to a file?

mans
  • 17,104
  • 45
  • 172
  • 321

1 Answers1

2

Can I remove the effect of it completely from the generated code?

If you mean removing any use of Boost.Log at compilation stage (e.g. by a preprocessor switch) then no, Boost.Log does not provide that. You will have to implement your own support for that, including conditional compilation of Boost.Log initialization and your own logging macros that expand to nothing when logging is disabled at compile time.

If you mean just disabling logs completely without removing the compile-time dependency then you can use core::set_logging_enabled or filters for that. It will still have small performance cost to check the condition for every log record, but no log records will be produced.

Can I add section to the logging at the same time that I am adding severity?

Yes, you can use channels for that. You can apply filters to the channel name to select which messages to keep and which to suppress. Here is a related answer.

possibility of sending different logging to different sinks so for example some logging goes to console and some other goes to a file?

Yes, again, this can be achieved with channels and filters. See the linked above SO answer describing that.

Community
  • 1
  • 1
Andrey Semashev
  • 10,046
  • 1
  • 17
  • 27