Signed-off-by: Jan Friesse <jfriesse@redhat.com>
log_target |= LOG_TARGET_STDERR;
}
log_target |= LOG_TARGET_STDERR;
}
- res = log_init(QNETD_PROGRAM_NAME, log_target);
+ res = log_init(QNETD_PROGRAM_NAME, log_target, LOG_DAEMON);
if (res == -1) {
errx(1, "Can't initialize logging");
}
if (res == -1) {
errx(1, "Can't initialize logging");
}
static int log_config_target = 0;
static int log_config_debug = 0;
static int log_config_priority_bump = 0;
static int log_config_target = 0;
static int log_config_debug = 0;
static int log_config_priority_bump = 0;
+static int log_config_syslog_facility = 0;
static char *log_config_ident = NULL;
static const char log_month_str[][4] = {
static char *log_config_ident = NULL;
static const char log_month_str[][4] = {
-log_init(const char *ident, int target)
+log_init(const char *ident, int target, int syslog_facility)
- log_config_target = target;
log_config_ident = strdup(ident);
if (log_config_ident == NULL) {
return (-1);
}
log_config_ident = strdup(ident);
if (log_config_ident == NULL) {
return (-1);
}
- if (log_config_target & LOG_TARGET_SYSLOG) {
- openlog(QNETD_PROGRAM_NAME, LOG_PID, LOG_DAEMON);
- }
+ log_set_target(target, syslog_facility);
log_config_priority_bump = enabled;
}
log_config_priority_bump = enabled;
}
+void
+log_set_target(int target, int syslog_facility)
+{
+
+ log_close();
+
+ log_config_target = target;
+ log_config_syslog_facility = syslog_facility;
+
+ if (log_config_target & LOG_TARGET_SYSLOG) {
+ openlog(log_config_ident, LOG_PID, log_config_syslog_facility);
+ }
+}
+
void
log_msg_decode_error(int ret)
{
void
log_msg_decode_error(int ret)
{
#define log_err(priority, str) log_printf(priority, "%s (%d): %s", \
str, errno, strerror(errno))
#define log_err(priority, str) log_printf(priority, "%s (%d): %s", \
str, errno, strerror(errno))
-extern int log_init(const char *ident, int target);
+extern int log_init(const char *ident, int target, int syslog_facility);
extern void log_printf(int priority, const char *format, ...)
__attribute__((__format__(__printf__, 2, 3)));
extern void log_printf(int priority, const char *format, ...)
__attribute__((__format__(__printf__, 2, 3)));
extern void log_set_priority_bump(int enabled);
extern void log_set_priority_bump(int enabled);
+extern void log_set_target(int target, int syslog_facility);
+
extern void log_msg_decode_error(int ret);
#ifdef __cplusplus
extern void log_msg_decode_error(int ret);
#ifdef __cplusplus