static bool show_color = false;
static bool show_location = false;
-/* Akin to glibc's __abort_msg; which is private and we hance cannot
+/* Akin to glibc's __abort_msg; which is private and we hence cannot
* use here. */
static char *log_abort_msg = NULL;
return console_fd;
}
- log_debug("Succesfully opened /dev/console for logging.");
+ log_debug("Successfully opened /dev/console for logging.");
} else
console_fd = STDERR_FILENO;
return -errno;
}
- log_debug("Succesfully opened /dev/kmsg for logging.");
+ log_debug("Successfully opened /dev/kmsg for logging.");
return 0;
}
} else
syslog_is_stream = false;
- log_debug("Succesfully opened syslog for logging.");
+ log_debug("Successfully opened syslog for logging.");
return 0;
if (log_target != LOG_TARGET_AUTO ||
getpid() == 1 ||
- isatty(STDERR_FILENO) <= 0)) {
+ isatty(STDERR_FILENO) <= 0) {
if (log_target == LOG_TARGET_AUTO ||
log_target == LOG_TARGET_SYSLOG_OR_KMSG ||
log_target = target;
}
+void log_close(void) {
+ log_close_console();
+ log_close_kmsg();
+ log_close_syslog();
+}
+
void log_set_max_level(int level) {
assert((level & LOG_PRIMASK) == level);
}
static int write_to_console(
- int level,
- const char*file,
- int line,
- const char *func,
- const char *buffer) {
+ int level,
+ const char*file,
+ int line,
+ const char *func,
+ const char *buffer) {
char location[64];
struct iovec iovec[5];
if (syslog_fd < 0)
return 0;
- snprintf(header_priority, sizeof(header_priority), "<%i>", LOG_MAKEPRI(LOG_DAEMON, LOG_PRI(level)));
+ snprintf(header_priority, sizeof(header_priority), "<%i>", level);
char_array_0(header_priority);
t = (time_t) (now(CLOCK_REALTIME) / USEC_PER_SEC);
if (kmsg_fd < 0)
return 0;
- snprintf(header_priority, sizeof(header_priority), "<%i>", LOG_PRI(level));
+ snprintf(header_priority, sizeof(header_priority), "<%i>", level);
char_array_0(header_priority);
snprintf(header_pid, sizeof(header_pid), "[%lu]: ", (unsigned long) getpid());
if (log_target == LOG_TARGET_NULL)
return 0;
+ /* Patch in LOG_DAEMON facility if necessary */
+ if ((level & LOG_FACMASK) == 0)
+ level = LOG_DAEMON | LOG_PRI(level);
+
do {
char *e;
int k = 0;