mirror of
https://github.com/emqx/neuron.git
synced 2026-10-23 18:37:45 +08:00
Merge pull request #1689 from eeff/eeff/dev
feat: syslog message add priority
This commit is contained in:
@@ -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 = "<P>%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
|
||||
|
||||
+23
@@ -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));
|
||||
|
||||
@@ -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 = "<P>%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
|
||||
|
||||
Reference in New Issue
Block a user