mirror of
				https://github.com/Telecominfraproject/wlan-ap.git
				synced 2025-10-30 18:07:52 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			94 lines
		
	
	
		
			3.0 KiB
		
	
	
	
		
			Diff
		
	
	
	
	
	
			
		
		
	
	
			94 lines
		
	
	
		
			3.0 KiB
		
	
	
	
		
			Diff
		
	
	
	
	
	
| From 10e0cb60aca9bfd50e5d0d49039752d6a8b91baa Mon Sep 17 00:00:00 2001
 | |
| From: John Crispin <john@phrozen.org>
 | |
| Date: Thu, 23 Jul 2020 16:09:28 +0200
 | |
| Subject: [PATCH 03/40] 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    | 48 +++++++++++++++++++
 | |
|  2 files changed, 51 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 ba9c124c8b..fdeb1877fe 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..e1b6b11497
 | |
| --- /dev/null
 | |
| +++ b/package/system/ubox/patches/100-log-prio.patch
 | |
| @@ -0,0 +1,48 @@
 | |
| +Index: ubox-2019-06-16-4df34a4d/log/logread.c
 | |
| +===================================================================
 | |
| +--- ubox-2019-06-16-4df34a4d.orig/log/logread.c
 | |
| ++++ ubox-2019-06-16-4df34a4d/log/logread.c
 | |
| +@@ -66,6 +66,7 @@ static int log_type = LOG_STDOUT;
 | |
| + static int log_size, log_udp, log_follow, log_trailer_null = 0;
 | |
| + static int log_timestamp;
 | |
| + static int logd_conn_tries = LOGD_CONNECT_RETRY;
 | |
| ++static int log_max_prio;
 | |
| + 
 | |
| + static const char* getcodetext(int value, CODE *codetable) {
 | |
| + 	CODE *i;
 | |
| +@@ -146,6 +147,8 @@ static int log_notify(struct blob_attr *
 | |
| + 	}
 | |
| + 	c = ctime(&t);
 | |
| + 	p = blobmsg_get_u32(tb[LOG_PRIO]);
 | |
| ++	if (log_max_prio && LOG_PRI(p) > log_max_prio)
 | |
| ++		return 0;
 | |
| + 	c[strlen(c) - 1] = '\0';
 | |
| + 
 | |
| + 	if (log_type == LOG_NET) {
 | |
| +@@ -216,6 +219,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;
 | |
| + }
 | |
| +@@ -290,7 +294,7 @@ int main(int argc, char **argv)
 | |
| + 
 | |
| + 	signal(SIGPIPE, SIG_IGN);
 | |
| + 
 | |
| +-	while ((ch = getopt(argc, argv, "u0fcs:l:r:F:p:S:P:h:e:t")) != -1) {
 | |
| ++	while ((ch = getopt(argc, argv, "u0fcs:l:r:F:p:S:P:h:e:tm:")) != -1) {
 | |
| + 		switch (ch) {
 | |
| + 		case 'u':
 | |
| + 			log_udp = 1;
 | |
| +@@ -337,6 +341,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
 | |
| 
 | 
