I have a project organized as follows:
All the "component" folders have the same structure. I am using the Boost.Log v2, and I am able to see all types of logs (trace, debug, ..., fatal) on the console, when I use them. I would like to use the very basic filtering mechanism shown in the documentation:
Here, a function "init" is called to perform the filtering. My question is: where is the correct place to put this filtering, in the case of my project, in such a way it will be valid everywhere in the project itself and if I need to change the default severity I would need to modify the code in just one place? Do I need like a configuration file where to put it? I was thinking to put it in every main.cpp inside every component but I think there are best solutions to do that. Thanks in advance.


There is only one
mainfunction per process. You need to initialize logging, including filtering, early in that function.If your project has multiple different executables then each executable has its own
mainfunction and you need to perform logging initialization in each of them. If you want to avoid code duplication, you can move the initialization to a common header and/or library that you would use in each of the executables. For example, move theinitfunction from your code snippet to a separate header and include and use it in everymainfunction.You can use settings files with Boost.Log, but that is entirely unrelated to code organization.