mirror of
https://github.com/Telecominfraproject/wlan-ap.git
synced 2025-10-29 09:32:34 +00:00
95 lines
3.0 KiB
Diff
95 lines
3.0 KiB
Diff
From c7cf22faf7dc1eff6ed56f7e24d1726766770279 Mon Sep 17 00:00:00 2001
|
|
From: John Crispin <john@phrozen.org>
|
|
Date: Thu, 23 Jul 2020 16:09:28 +0200
|
|
Subject: [PATCH 13/21] ubox: add log priority filtering
|
|
|
|
Allow logread to filer based on priority.
|
|
|
|
Signed-off-by: John Crispin <john@phrozen.org>
|
|
---
|
|
package/system/ubox/files/log.init | 4 +-
|
|
.../system/ubox/patches/100-log-prio.patch | 49 +++++++++++++++++++
|
|
2 files changed, 52 insertions(+), 1 deletion(-)
|
|
create mode 100644 package/system/ubox/patches/100-log-prio.patch
|
|
|
|
diff --git a/package/system/ubox/files/log.init b/package/system/ubox/files/log.init
|
|
index 250f805b44..34471bd64a 100644
|
|
--- a/package/system/ubox/files/log.init
|
|
+++ b/package/system/ubox/files/log.init
|
|
@@ -20,7 +20,8 @@ validate_log_section()
|
|
'log_port:port:514' \
|
|
'log_proto:or("tcp", "udp"):udp' \
|
|
'log_trailer_null:bool:0' \
|
|
- 'log_prefix:string'
|
|
+ 'log_prefix:string' \
|
|
+ 'log_max_prio:uinteger'
|
|
}
|
|
|
|
validate_log_daemon()
|
|
@@ -80,6 +81,7 @@ start_service_remote()
|
|
"tcp") [ "${log_trailer_null}" -eq 1 ] && procd_append_param command -0;;
|
|
esac
|
|
[ -z "${log_prefix}" ] || procd_append_param command -P "${log_prefix}"
|
|
+ [ -z "${log_max_prio}" ] || procd_append_param command -m "${log_max_prio}"
|
|
procd_close_instance
|
|
}
|
|
|
|
diff --git a/package/system/ubox/patches/100-log-prio.patch b/package/system/ubox/patches/100-log-prio.patch
|
|
new file mode 100644
|
|
index 0000000000..f1abfbd0e6
|
|
--- /dev/null
|
|
+++ b/package/system/ubox/patches/100-log-prio.patch
|
|
@@ -0,0 +1,49 @@
|
|
+Index: ubox-2019-12-31-0e34af14/log/logread.c
|
|
+===================================================================
|
|
+--- ubox-2019-12-31-0e34af14.orig/log/logread.c
|
|
++++ ubox-2019-12-31-0e34af14/log/logread.c
|
|
+@@ -68,6 +68,7 @@ static int log_timestamp;
|
|
+ static int logd_conn_tries = LOGD_CONNECT_RETRY;
|
|
+ static int facility_include;
|
|
+ static int facility_exclude;
|
|
++static int log_max_prio;
|
|
+
|
|
+ /* check for facility filter; return 0 if message shall be dropped */
|
|
+ static int check_facility_filter(int f)
|
|
+@@ -147,6 +148,9 @@ static int log_notify(struct blob_attr *
|
|
+ }
|
|
+ p = blobmsg_get_u32(tb[LOG_PRIO]);
|
|
+
|
|
++ if (log_max_prio && LOG_PRI(p) > log_max_prio)
|
|
++ return 0;
|
|
++
|
|
+ if (!check_facility_filter(LOG_FAC(p)))
|
|
+ return 0;
|
|
+
|
|
+@@ -233,6 +237,7 @@ static int usage(const char *prog)
|
|
+ " -u Use UDP as the protocol\n"
|
|
+ " -t Add an extra timestamp\n"
|
|
+ " -0 Use \\0 instead of \\n as trailer when using TCP\n"
|
|
++ " -m <priority> Only show messages with priority less or equal than <priority>\n"
|
|
+ "\n", prog);
|
|
+ return 1;
|
|
+ }
|
|
+@@ -307,7 +312,7 @@ int main(int argc, char **argv)
|
|
+
|
|
+ signal(SIGPIPE, SIG_IGN);
|
|
+
|
|
+- while ((ch = getopt(argc, argv, "u0fcs:l:z:Z:r:F:p:S:P:h:e:t")) != -1) {
|
|
++ while ((ch = getopt(argc, argv, "u0fcs:l:z:Z:r:F:p:S:P:h:e:tm:")) != -1) {
|
|
+ switch (ch) {
|
|
+ case 'u':
|
|
+ log_udp = 1;
|
|
+@@ -362,6 +367,9 @@ int main(int argc, char **argv)
|
|
+ case 't':
|
|
+ log_timestamp = 1;
|
|
+ break;
|
|
++ case 'm':
|
|
++ log_max_prio = atoi(optarg);
|
|
++ break;
|
|
+ default:
|
|
+ return usage(*argv);
|
|
+ }
|
|
--
|
|
2.25.1
|
|
|