Convert log calls to ulog() api
authorJo-Philipp Wich <jow@openwrt.org>
Wed, 25 Feb 2015 22:52:03 +0000 (23:52 +0100)
committerJo-Philipp Wich <jow@openwrt.org>
Wed, 25 Feb 2015 22:58:29 +0000 (23:58 +0100)
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
initd/early.c
initd/init.c
initd/mkdev.c
log.h
procd.c
state.c

index beb7b694323f767bdefab042bb956e2363df0a8f..5ee49ee3f5e7e6591e6a01a0f52e582fe9aa0a9e 100644 (file)
@@ -21,7 +21,6 @@
 #include <unistd.h>
 #include <stdlib.h>
 
-#include "../log.h"
 #include "init.h"
 
 static void
index 0d201bc33ffa46d1fad1488e7cc27082ae64869d..9818c4fbe5912308d844927d884746aad859806e 100644 (file)
@@ -72,6 +72,8 @@ main(int argc, char **argv)
 {
        pid_t pid;
 
+       ulog_open(ULOG_KMSG, LOG_DAEMON, "init");
+
        sigaction(SIGTERM, &sa_shutdown, NULL);
        sigaction(SIGUSR1, &sa_shutdown, NULL);
        sigaction(SIGUSR2, &sa_shutdown, NULL);
index 3471461f93bf28b1397bc7217a85f87bf7e03625..a9a2320fce807be7c04a152cd3758964f1975072 100644 (file)
@@ -28,8 +28,6 @@
 
 #include "init.h"
 
-#include "../log.h"
-
 static char **patterns;
 static int n_patterns;
 static char buf[PATH_MAX];
diff --git a/log.h b/log.h
index 968c1366d7c163eb739397b2ec0b059220b08036..bf86f1efb908cd247ff6f4486553fc98112964d6 100644 (file)
--- a/log.h
+++ b/log.h
 #ifndef __LOG_H
 #define __LOG_H
 
-#include <syslog.h>
+#include <libubox/ulog.h>
 
 #define DEBUG(level, fmt, ...) do { \
        if (debug >= level) { \
-               syslog(0, fmt, ## __VA_ARGS__); \
-               fprintf(stderr, "procd: %s(%d): " fmt, __func__, __LINE__, ## __VA_ARGS__); \
+               ulog(LOG_DEBUG, fmt, ## __VA_ARGS__); \
        } } while (0)
 
-#define LOG(fmt, ...) do { \
-               syslog(0, fmt, ## __VA_ARGS__); \
-               fprintf(stderr, "procd: "fmt, ## __VA_ARGS__); \
-       } while (0)
-
-#define ERROR(fmt, ...) do { \
-               syslog(0, fmt, ## __VA_ARGS__); \
-               fprintf(stderr, "procd: "fmt, ## __VA_ARGS__); \
-       } while (0)
+#define LOG   ULOG_INFO
+#define ERROR ULOG_ERR
 
 extern unsigned int debug;
 
diff --git a/procd.c b/procd.c
index 7528e604ebdc546b381bc0febd99396202fa336f..e41d98a6a43a6aa8d3b0124f6ed11c9d49fbf1d9 100644 (file)
--- a/procd.c
+++ b/procd.c
@@ -43,6 +43,8 @@ int main(int argc, char **argv)
        int ch;
        char *dbglvl = getenv("DBGLVL");
 
+       ulog_open(ULOG_KMSG, LOG_DAEMON, "procd");
+
        if (dbglvl) {
                debug = atoi(dbglvl);
                unsetenv("DBGLVL");
diff --git a/state.c b/state.c
index 0896e1ae34f6430ad7abdee5ba5d46f3dfc238a3..22a06a14f9be2c61714e89494cd82bde97845281 100644 (file)
--- a/state.c
+++ b/state.c
@@ -116,6 +116,9 @@ static void state_enter(void)
                procd_inittab_run("askconsole");
                procd_inittab_run("askfirst");
                procd_inittab_run("sysinit");
+
+               // switch to syslog log channel
+               ulog_open(ULOG_SYSLOG, LOG_DAEMON, "procd");
                break;
 
        case STATE_RUNNING: