commit 4e9ffc25fa7b71bbba8c8539afa852a41221b69a
parent cb583e0afe36899f1b0fd0f5439fc1676d59326c
Author: Jacob R. Edwards <jacobouno@protonmail.com>
Date: Thu, 26 Aug 2021 12:42:33 -0700
Allow flipping the log level in the log command
Since it's a short and useful addition I believe it's worthy. Often
you want to have all but 'info' or the like and this makes doing
so easy.
Diffstat:
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/aps/command.c b/aps/command.c
@@ -223,17 +223,20 @@ aps_status(struct aps *aps, int s, int argc, char **argv)
char *
aps_loglevel(struct aps *aps, int s, int argc, char **argv)
{
+ int flip;
int i;
int level, mask;
+ flip = (argc && strcmp(argv[0], "!") == 0);
+
level = 0;
- for (i = 0; i < argc; ++i) {
+ for (i = flip; i < argc; ++i) {
if ((mask = strlevel(argv[i])) < 0)
return "invalid log level";
level |= mask;
}
- aps->loglevel = level;
+ aps->loglevel = (flip ? ~level : level);
return NULL;
}