summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJo-Philipp Wich <jow@openwrt.org>2015-02-25 23:52:03 +0100
committerJo-Philipp Wich <jow@openwrt.org>2015-02-25 23:58:29 +0100
commit4bccbfa967d756b8c84a62ea4752e936d8545a73 (patch)
treedcb96ec1bae2005b3840493af73f12002f74d97f
parent7676df3226da5391c2dfda2ed29a40500e04e15b (diff)
downloadunitd-4bccbfa967d756b8c84a62ea4752e936d8545a73.tar
unitd-4bccbfa967d756b8c84a62ea4752e936d8545a73.zip
Convert log calls to ulog() api
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
-rw-r--r--initd/early.c1
-rw-r--r--initd/init.c2
-rw-r--r--initd/mkdev.c2
-rw-r--r--log.h16
-rw-r--r--procd.c2
-rw-r--r--state.c3
6 files changed, 11 insertions, 15 deletions
diff --git a/initd/early.c b/initd/early.c
index beb7b69..5ee49ee 100644
--- a/initd/early.c
+++ b/initd/early.c
@@ -21,7 +21,6 @@
#include <unistd.h>
#include <stdlib.h>
-#include "../log.h"
#include "init.h"
static void
diff --git a/initd/init.c b/initd/init.c
index 0d201bc..9818c4f 100644
--- a/initd/init.c
+++ b/initd/init.c
@@ -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);
diff --git a/initd/mkdev.c b/initd/mkdev.c
index 3471461..a9a2320 100644
--- a/initd/mkdev.c
+++ b/initd/mkdev.c
@@ -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 968c136..bf86f1e 100644
--- a/log.h
+++ b/log.h
@@ -15,23 +15,15 @@
#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 7528e60..e41d98a 100644
--- 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 0896e1a..22a06a1 100644
--- 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: