]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
lib/log kr_log_fmt(): pass parameters more properly
authorVladimír Čunát <vladimir.cunat@nic.cz>
Wed, 4 Aug 2021 19:11:51 +0000 (21:11 +0200)
committerTomas Krizek <tomas.krizek@nic.cz>
Tue, 10 Aug 2021 18:16:58 +0000 (20:16 +0200)
Systemd docs say:
> Those arguments must contain valid journal entries including
> the variable name, e.g. "CODE_FILE=src/foo.c", [...]

I tried that passing all three strings empty (without variable name)
wouldn't result into the line getting logged; the suggested style does.

daemon/lua/sandbox.lua.in
lib/log.h

index 4a513b258da769f40b589472167b592500201240..8eebbfab7633f679228934e18f7b9ad470c94dde 100644 (file)
@@ -31,7 +31,8 @@ local function curr_file() return debug.getinfo(4,'S').source end
 local function curr_line() return debug.getinfo(4,'l').currentline end
 
 local function log_fmt(grp, level, fmt, ...)
-       ffi.C.kr_log_fmt(grp, level, 'CODE_FILE='..curr_file(), 'CODE_LINE='..curr_line(), '',
+       ffi.C.kr_log_fmt(grp, level,
+                       'CODE_FILE='..curr_file(), 'CODE_LINE='..curr_line(), 'CODE_FUNC=',
                        '[%-6s] %s\n', ffi.C.kr_log_grp2name(grp), string.format(fmt, ...))
 end
 
index 4029632049e84f58a9d69f74ad055459eeacc0a4..f5be3da3b8eb9f2d7d6a23d34e6f05afe5ec0770 100644 (file)
--- a/lib/log.h
+++ b/lib/log.h
@@ -261,6 +261,11 @@ bool kr_log_is_debug_fun(enum kr_log_group group, const struct kr_request *req);
 
 /* Helpers "internal" to log.* */
 
+/** @internal
+ *
+ * If you don't have location, pass ("CODE_FILE=", "CODE_LINE=", "CODE_FUNC=")
+ * Others than systemd don't utilize these metadata.
+ */
 KR_EXPORT KR_PRINTF(6)
 void kr_log_fmt(enum kr_log_group group, kr_log_level_t level, const char *file, const char *line,
                const char *func, const char *fmt, ...);