i want to log a lot of events in a dynamically search-algorithm (e.g. information about convergence to global optimum). This logging should have a switch to turn it off/on. Now there are a lot of possibilities to achieve that:
- implement a log-version and a non-log-version of the algorithm -> redundancy
- use macros -> ugly and not that safe
- use a c++ logging library (or: use 1% of the functional range of a logging library).
I decided to use Pantheios, especially because of the performance claims made (don't want to lose much performance because of this logging, which is only needed in development). I have to admit, that i don't need much of the functionality of this library, but i thought i would be a much nicer/safer way to use it. Maybe there would be a better suited alternative i don't know of (i need compile-time decisions only for logging -> don't know if there are logging-libraries designed for that purpose).
After compiling, installing and finally linking (no success with manually linking, but with the scons building tool; using gcc -> explicit linking), i wanted to try a little example.
Let's reduce that to something like the following:
#include "pantheios/pantheios.hpp"
#include "pantheios/frontends/stock.h"
const PAN_CHAR_T PANTHEIOS_FE_PROCESS_IDENTITY[] = "pantheios_test"; // specify process identity
int main()
{
pantheios::log_ALERT("alert-event");
pantheios::log_DEBUG("debug-event");
pantheios::log_INFORMATIONAL("just information");
return 1;
}
Linking is done with the following files:
LIBS=['pantheios.1.core.gcc44', 'pantheios.1.be.fprintf.gcc44', 'pantheios.1.bec.fprintf.gcc44',
'pantheios.1.fe.all.gcc44', 'pantheios.1.util.gcc44']
The simple question is now: how to switch the console-output off/on? How to choose the severity-level which is given to the back-end?
Looking into the documentation lead me to a lot of functions which take a severity level, but these functions are automatically called once for initialization. I know that dynamic changes of severity-levels are possible. I don't know exactly, where i change these settings. They should be in the front-end component i think. Is linking to "fe_all" already some kind of decisions which level is logged ad which level isn't?
It should be relatively easy because in my case, i only need a compile-time decision about logging on/off.
Thanks for your help.
Sascha