summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Crispin <blogic@openwrt.org>2013-09-01 20:40:53 +0200
committerJohn Crispin <blogic@openwrt.org>2013-09-03 19:38:50 +0200
commit1c01a5137402cfd1bc7557118401f3b90c305b78 (patch)
tree5b708911891e1e40b3c3e0694dee655c7c6011c3
parent85a5ce27f5f02e4ddab6916d69ba7f7375d289d4 (diff)
downloadunitd-1c01a5137402cfd1bc7557118401f3b90c305b78.tar
unitd-1c01a5137402cfd1bc7557118401f3b90c305b78.zip
logread: fix the facility name reporting
http://patchwork.openwrt.org/patch/3978/ Signed-off-by: Mike Brady<mikebrady@eircom.net>
-rw-r--r--logread.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/logread.c b/logread.c
index 1bf3ed8..bd8c697 100644
--- a/logread.c
+++ b/logread.c
@@ -60,6 +60,16 @@ static const char *log_file, *log_ip, *log_port, *pid_file;
static int log_type = LOG_STDOUT;
static int log_size, log_udp;
+static const char* getcodetext(int value, CODE *codetable) {
+ CODE *i;
+
+ if (value >= 0)
+ for (i = codetable; i->c_val != -1; i++)
+ if (i->c_val == value)
+ return (i->c_name);
+ return "<unknown>";
+};
+
static void log_handle_reconnect(struct uloop_timeout *timeout)
{
sender.fd = usock((log_udp) ? (USOCK_UDP) : (USOCK_TCP), log_ip, log_port);
@@ -149,7 +159,7 @@ static int log_notify(struct ubus_context *ctx, struct ubus_object *obj,
}
} else {
snprintf(buf, sizeof(buf), "%s %s.%s%s %s\n",
- c, facilitynames[LOG_FAC(p)].c_name, prioritynames[LOG_PRI(p)].c_name,
+ c, getcodetext(LOG_FAC(p) << 3, facilitynames), getcodetext(LOG_PRI(p), prioritynames),
(blobmsg_get_u32(tb[LOG_SOURCE])) ? ("") : (" kernel:"),
method);
write(sender.fd, buf, strlen(buf));
@@ -217,6 +227,8 @@ enum {
__READ_MAX
};
+
+
static const struct blobmsg_policy read_policy[] = {
[READ_LINE] = { .name = "lines", .type = BLOBMSG_TYPE_ARRAY },
};
@@ -252,7 +264,7 @@ static void read_cb(struct ubus_request *req, int type, struct blob_attr *msg)
c[strlen(c) - 1] = '\0';
printf("%s %s.%s%s %s\n",
- c, facilitynames[LOG_FAC(p)].c_name, prioritynames[LOG_PRI(p)].c_name,
+ c, getcodetext(LOG_FAC(p) << 3, facilitynames), getcodetext(LOG_PRI(p), prioritynames),
(blobmsg_get_u32(tb[LOG_SOURCE])) ? ("") : (" kernel:"),
blobmsg_get_string(tb[LOG_MSG]));
}