[LEDE-DEV] [PATCH ubox] Add logd priority filtering option
Ron Brash
ron.brash at gmail.com
Wed Jul 5 08:01:29 PDT 2017
Hello all,
Here is a repost of the previous patch split into a single one.
This patch adds the logger priority filtering needed by one of our
clients. For example, they who remain unnamed, are running a really
stripped down system that wants to parse logs at the logger level.
They have some code to present logs to a user, but they want to
minimise the logging "below" and opted to use the unused field
connloglevel.
Ron
--
Ron Brash
CTO & Co-founder of Atlants Embedded Inc.
www.atlantsembedded.com
------------------------------------------------------------------
Cell +1 438 880 6441
Email ron.brash at gmail.com
LinkedIn ca.linkedin.com/in/ronbrash/
------------------------------------------------------------------
Signed-off-by: “Ron Brash <“ron.brash at gmail.com”>
---
log/logd.c | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/log/logd.c b/log/logd.c
index 07aee2b..a60cb8f 100644
--- a/log/logd.c
+++ b/log/logd.c
@@ -27,6 +27,7 @@
#include "syslog.h"
int debug = 0;
+int priority = 7;
static struct blob_buf b;
static struct ubus_auto_conn conn;
static LIST_HEAD(clients);
@@ -182,6 +183,9 @@ ubus_notify_log(struct log_head *l)
if (list_empty(&clients))
return;
+ if((l->priority & 7) > priority) {
+ return; // skip if greater (logger level filtering)
+ }
blob_buf_init(&b, 0);
blobmsg_add_string(&b, "msg", l->data);
blobmsg_add_u32(&b, "id", l->id);
@@ -214,13 +218,21 @@ main(int argc, char **argv)
int ch, log_size = 16;
signal(SIGPIPE, SIG_IGN);
- while ((ch = getopt(argc, argv, "S:")) != -1) {
+ while ((ch = getopt(argc, argv, "P:S:")) != -1) {
switch (ch) {
case 'S':
log_size = atoi(optarg);
if (log_size < 1)
log_size = 16;
break;
+ case 'P':
+ priority = atoi(optarg);
+ if (priority < 0)
+ priority = 0;
+ else if(priority > 7) {
+ priority = 7; // bounds check
+ }
+ break;
}
}
log_size *= 1024;
--
2.7.4
More information about the Lede-dev
mailing list