Hi,
I have been trying to find a clever way of removing and adding logging function calls from a C++ programme. The log functions call into a "logger" class, but I would like to remove the different log levels with the least amount of headache for the maintainers.
We already have the normal file #undef WARN, etc. procedure, but I am trying to improve this. Basically, trying to write code such that:
MODULE_LOG ("MyModule", ALARM);
int MyClass::Function (int param)
{
ALARM ("Print");
WARN ("No Print");
}
This would ideally compile into just:
int MyClass::Function (int param)
{
logger::alarm_print_function ("Print");
}
Hence, the "WARN" definition has been removed.
If the maintainer wanted to see the WARN messages, then they could just change the code such that:
MODULE_LOG ("MyModule", ALARM, WARN);
This would ideally compile into just:
int MyClass::Function (int param)
{
logger::alarm_print_function ("Print");
logger::warn_print_function ("No Print");
}
This way the maintainer can just update a single module. As said, this can be done through the normal #undef/#define of WARN, etc.
I was wondering if there was a more clever way of doing this?
Thanks.