diff --git a/dev.conf b/dev.conf index 5a7f31289..86b75c951 100644 --- a/dev.conf +++ b/dev.conf @@ -6,10 +6,10 @@ file perms = 666 stdout_format = "%d:%ms [%V] [%c] %f:%L %m%n" file_format = "%d:%ms [%V] %f:%L %m%n" -syslog = "%d:%ms %H neuron[%p]: [%V] [%c] %f:%L %m%n" +syslog = "

%d:%ms %H neuron[%p]: [%V] [%c] %f:%L %m%n" [rules] *.* "./logs/%c.log", 25MB * 1 ~ "./logs/%c.#2r.log"; file_format *.* >stdout; stdout_format -*.* $remote_syslog; syslog +*.* $remote_syslog,"%V"; syslog diff --git a/src/main.c b/src/main.c index d7d9f9edc..d42c2f119 100644 --- a/src/main.c +++ b/src/main.c @@ -62,8 +62,31 @@ static void sig_handler(int sig) exit(-1); } +static inline char syslog_priority(const char *level) +{ + switch (level[0]) { + case 'D': // DEBUG + return '7'; + case 'I': // INFO + return '6'; + case 'N': // NOTICE + return '5'; + case 'W': // WARN + return '4'; + case 'E': // ERROR + return '3'; + case 'F': // FATAL + return '2'; + default: // UNKNOWN + return '1'; + } +} + static int remote_syslog(zlog_msg_t *msg) { + // fix priority + msg->buf[1] = syslog_priority(msg->path); + sendto(g_remote_syslog_ctx.fd, msg->buf, msg->len, 0, (const struct sockaddr *) &g_remote_syslog_ctx.addr, sizeof(g_remote_syslog_ctx.addr)); diff --git a/zlog.conf b/zlog.conf index 03cae35b4..e5e1cf2e6 100644 --- a/zlog.conf +++ b/zlog.conf @@ -5,9 +5,9 @@ file perms = 666 [formats] simple = "%d:%ms [%V] %f:%L %m%n" -syslog = "%d:%ms %H neuron[%p]: [%V] [%c] %f:%L %m%n" +syslog = "

%d:%ms %H neuron[%p]: [%V] [%c] %f:%L %m%n" [rules] *.* "./logs/%c.log", 25MB * 1 ~ "./logs/%c.#2r.log"; simple -*.* $remote_syslog; syslog +*.* $remote_syslog,"%V"; syslog