Fix log_msg().

* Added new constant LOG_WITHOUT_SYSLOG to be able to print messages to
    stderr only.
  * Renamed LOG_STDERR_MASK as LOG_VERBOSITY_MASK for a better understanding.
This commit is contained in:
Franck Joncourt
2013-06-16 21:16:25 +02:00
parent b48295c69b
commit 935565cd90
2 changed files with 16 additions and 14 deletions

View File

@@ -154,7 +154,7 @@ log_msg(int level, char* msg, ...)
{
va_list ap, apse;
if (level > verbosity)
if ((level & LOG_VERBOSITY_MASK) > verbosity)
return;
va_start(ap, msg);
@@ -175,18 +175,19 @@ log_msg(int level, char* msg, ...)
fflush(stderr);
va_end(apse);
if(LOG_STDERR_ONLY & level)
{
va_end(ap);
return;
}
/* Remove the log to stderr flag from the log level value.
*/
level &= LOG_STDERR_MASK;
}
/* If the message has not to be printed to the syslog, we return */
if (LOG_WITHOUT_SYSLOG & level)
{
va_end(ap);
return;
}
/* Remove the log to stderr flag from the log level value.
*/
level &= LOG_VERBOSITY_MASK;
/* Send the message to syslog.
*/
openlog(log_name, LOG_PID, syslog_fac);

View File

@@ -39,9 +39,10 @@
* LOG_STDERR_ONLY can be set to send a message stderr with a copy to
* syslog as well.
*/
#define LOG_STDERR 0x1000
#define LOG_STDERR_ONLY 0x3000
#define LOG_STDERR_MASK 0x0FFF
#define LOG_STDERR 0x1000
#define LOG_WITHOUT_SYSLOG 0x2000
#define LOG_STDERR_ONLY (LOG_STDERR | LOG_WITHOUT_SYSLOG)
#define LOG_VERBOSITY_MASK 0x0FFF
#define LOG_DEFAULT_VERBOSITY LOG_WARNING /*!< Default verbosity to use */