]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
daemon/engine: warning when log_groups contains a non-existent group
authorOto Šťáva <oto.stava@nic.cz>
Fri, 24 Feb 2023 10:08:59 +0000 (11:08 +0100)
committerVladimír Čunát <vladimir.cunat@nic.cz>
Thu, 2 Mar 2023 11:51:31 +0000 (11:51 +0000)
Until now, kresd would refuse to start when a log_groups Lua call
contained a non-existent group. After this change, only a warning is
printed, which helps during development while switching between branches
with new logging groups. I don't think changing the configuration all
the time just for a logging group is warranted.

daemon/engine.c
daemon/lua/log.test.lua

index 26c225f39e65adda281c058181f73a41228d1598..7ee56512166300d9e69b6f69b1c0c992b6b7e9bb 100644 (file)
@@ -229,11 +229,14 @@ static int l_log_groups(lua_State *L)
                        const char *grp_str = lua_tostring(L, -1);
                        if (!grp_str)
                                goto bad_call;
+
                        enum kr_log_group grp = kr_log_name2grp(grp_str);
-                       if (grp < 0)
-                               lua_error_p(L, "unknown log group '%s'", lua_tostring(L, -1));
+                       if (grp >= 0) {
+                               kr_log_group_add(grp);
+                       } else {
+                               kr_log_warning(SYSTEM, "WARNING: unknown log group '%s'\n", lua_tostring(L, -1));
+                       }
 
-                       kr_log_group_add(grp);
                        ++idx;
                        lua_pop(L, 1);
                }
index 197aa74cc71478426559789588f9ec23ad40defc..ec5abd28c64301e29961881efa723e7a9371805e 100644 (file)
@@ -30,8 +30,8 @@ local function test_log_groups()
        same(log_groups({'devel'}), {'devel'}, 'another call overrides previously set groups')
        same(log_groups({'devel', 'system'}), {'system', 'devel'}, 'configure multiple groups')
        same(log_groups({}), {}, 'clear groups with empty table')
+       same(log_groups({'nonexistent'}), {}, "nonexistent group is ignored")
        boom(log_groups, { 'string' }, "group argument can't be string")
-       boom(log_groups, { {'nonexistent'} }, "nonexistent group can't be added")
        boom(log_groups, { 1, 2 }, "group doesn't take multiple arguments")
 end