I wrote a logging mechanism with several log levels.
LOG_FATAL(s)
LOG_ERROR(s)
LOG_WARN(s)
...
Now I want to be able to activate or deactivate the logging for some modules.
What I do now:
#ifdef MOUDLE_LOG_ON
MODULE_LOG_FATAL(s) LOG_FATAL(s)
MODULE_LOG_ERROR(s) LOG_ERROR(s)
MODULE_LOG_WARN(s) LOG_WARN(s)
...
#else
MODULE_LOG_FATAL(s)
MODULE_LOG_ERROR(s)
MODULE_LOG_WARN(s)
...
#endif
Is there a way to place the prefixing in a macro to use it like this:
SETUPLOGGING(MODULE)
I am wondering if using macros and inline functions could solve your issue:
After preprocessing, this produces: