Reputation: 4155
I intend to use syslog for logging in an application. I need to be able to disable logging, at compile time, perhaps using a macro. Is this possible to do with the syslog facilities, or do I need to wrap syslog in my own macros/functions? The ability to disable/enable log messages based on their priority is a plus.
Upvotes: 1
Views: 1590
Reputation: 80771
Maybe you could wrap a call to setlogmask in define block.
setlogmask sets a mask (the “logmask”) that determines which future syslog calls shall be ignored. If a program has not called setlogmask, syslog doesn't ignore any calls. You can use setlogmask to specify that messages of particular priorities shall be ignored in the future.
something like this :
#ifdef LOG_LEVEL1
setlogmask (LOG_UPTO (LOG_NOTICE));
#endif
#ifdef LOG_LEVEL2
setlogmask (LOG_UPTO (LOG_WARNING));
#endif
Upvotes: 1