#include <unistd.h>
#include <stdio.h>
+#define SYSLOG_NAMES
+#include <syslog.h>
+
#include <libubox/blobmsg_json.h>
#include <libubox/usock.h>
#include <libubox/uloop.h>
{
struct blob_attr *tb[__LOG_MAX];
char buf[256];
+ uint32_t p;
char *str;
time_t t;
char *c;
t = blobmsg_get_u64(tb[LOG_TIME]) / 1000;
c = ctime(&t);
+ p = blobmsg_get_u32(tb[LOG_PRIO]);
c[strlen(c) - 1] = '\0';
str = blobmsg_format_json(msg, true);
- snprintf(buf, sizeof(buf), "%s - %s: %s\n",
- c, (blobmsg_get_u32(tb[LOG_SOURCE])) ? ("syslog") : ("kernel"), method);
+ snprintf(buf, sizeof(buf), "%s %s.%s%s %s\n",
+ c, facilitynames[LOG_FAC(p)].c_name, prioritynames[LOG_PRI(p)].c_name,
+ (blobmsg_get_u32(tb[LOG_SOURCE])) ? ("") : (" kernel:"),
+ method);
write(sender.fd, buf, strlen(buf));
free(str);
return;
blobmsg_for_each_attr(cur, _tb[READ_LINE], rem) {
struct blob_attr *tb[__LOG_MAX];
+ uint32_t p;
char *c;
if (blobmsg_type(cur) != BLOBMSG_TYPE_TABLE)
continue;
t = blobmsg_get_u64(tb[LOG_TIME]);
+ p = blobmsg_get_u32(tb[LOG_PRIO]);
c = ctime(&t);
c[strlen(c) - 1] = '\0';
- printf("%s - %s: %s\n",
- c, (blobmsg_get_u32(tb[LOG_SOURCE])) ? ("syslog") : ("kernel"),
+
+ printf("%s %s.%s%s %s\n",
+ c, facilitynames[LOG_FAC(p)].c_name, prioritynames[LOG_PRI(p)].c_name,
+ (blobmsg_get_u32(tb[LOG_SOURCE])) ? ("") : (" kernel:"),
blobmsg_get_string(tb[LOG_MSG]));
}
}