[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 3/4] misc: Allow selective disabling of debug conditionals
From: |
Glenn Washburn |
Subject: |
[PATCH 3/4] misc: Allow selective disabling of debug conditionals |
Date: |
Fri, 19 Mar 2021 22:06:48 -0500 |
Sometimes you know only know which debug logging conditionals you want to
turn off. Now debug log messages can be excluded by specifying the
conditional in the $debug string with a prepended dash. So say you want
all debug logging on except for btrfs and scripting, then set
debug=all,-btrfs,-scripting.
Signed-off-by: Glenn Washburn <development@efficientek.com>
---
grub-core/kern/misc.c | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/grub-core/kern/misc.c b/grub-core/kern/misc.c
index 11b8592c8..73563b59b 100644
--- a/grub-core/kern/misc.c
+++ b/grub-core/kern/misc.c
@@ -168,7 +168,19 @@ grub_debug_enabled (const char * condition)
if (!debug)
return 0;
- if (grub_strword (debug, "all") || grub_strword (debug, condition))
+ if (grub_strword (debug, "all"))
+ {
+ if (debug[3] == '\0')
+ return 1;
+ const char *ptr = NULL;
+ ptr = grub_strstr (debug, condition);
+ if (ptr > debug && *(ptr-1) == '-'
+ && (*(ptr + grub_strlen (condition)) == '\0'
+ || grub_iswordseparator (*(ptr + grub_strlen (condition)))))
+ return 0;
+ return 1;
+ }
+ else if (grub_strword (debug, condition))
return 1;
return 0;
--
2.27.0