libimcv: Disable default syslog() logging if not supported
This commit is contained in:
parent
fb7cb97d6e
commit
09e5f15a13
|
@ -20,7 +20,9 @@
|
|||
#include <utils/utils.h>
|
||||
#include <pen/pen.h>
|
||||
|
||||
#ifdef HAVE_SYSLOG
|
||||
#include <syslog.h>
|
||||
#endif
|
||||
|
||||
#define IMCV_DEBUG_LEVEL 1
|
||||
#define IMCV_DEFAULT_POLICY_SCRIPT "ipsec _imv_policy"
|
||||
|
@ -62,9 +64,6 @@ static bool imcv_stderr_quiet;
|
|||
*/
|
||||
static void imcv_dbg(debug_t group, level_t level, char *fmt, ...)
|
||||
{
|
||||
int priority = LOG_INFO;
|
||||
char buffer[8192];
|
||||
char *current = buffer, *next;
|
||||
va_list args;
|
||||
|
||||
if (level <= imcv_debug_level)
|
||||
|
@ -78,22 +77,30 @@ static void imcv_dbg(debug_t group, level_t level, char *fmt, ...)
|
|||
va_end(args);
|
||||
}
|
||||
|
||||
/* write in memory buffer first */
|
||||
va_start(args, fmt);
|
||||
vsnprintf(buffer, sizeof(buffer), fmt, args);
|
||||
va_end(args);
|
||||
|
||||
/* do a syslog with every line */
|
||||
while (current)
|
||||
#ifdef HAVE_SYSLOG
|
||||
{
|
||||
next = strchr(current, '\n');
|
||||
if (next)
|
||||
int priority = LOG_INFO;
|
||||
char buffer[8192];
|
||||
char *current = buffer, *next;
|
||||
|
||||
/* write in memory buffer first */
|
||||
va_start(args, fmt);
|
||||
vsnprintf(buffer, sizeof(buffer), fmt, args);
|
||||
va_end(args);
|
||||
|
||||
/* do a syslog with every line */
|
||||
while (current)
|
||||
{
|
||||
*(next++) = '\0';
|
||||
next = strchr(current, '\n');
|
||||
if (next)
|
||||
{
|
||||
*(next++) = '\0';
|
||||
}
|
||||
syslog(priority, "[HSR] %s\n", current);
|
||||
current = next;
|
||||
}
|
||||
syslog(priority, "[HSR] %s\n", current);
|
||||
current = next;
|
||||
}
|
||||
#endif /* HAVE_SYSLOG */
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -127,7 +134,9 @@ bool libimcv_init(bool is_imv)
|
|||
|
||||
/* activate the imcv debugging hook */
|
||||
dbg = imcv_dbg;
|
||||
#ifdef HAVE_SYSLOG
|
||||
openlog("imcv", 0, LOG_DAEMON);
|
||||
#endif
|
||||
|
||||
if (!lib->plugins->load(lib->plugins,
|
||||
lib->settings->get_str(lib->settings, "libimcv.load",
|
||||
|
@ -197,4 +206,3 @@ void libimcv_deinit(void)
|
|||
library_deinit();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue