From: Vladimír Čunát Date: Wed, 4 Aug 2021 19:11:51 +0000 (+0200) Subject: lib/log kr_log_fmt(): pass parameters more properly X-Git-Tag: v5.4.1~3^2~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=257e5cbd53052a898cd401ce716baefbe1db4a37;p=thirdparty%2Fknot-resolver.git lib/log kr_log_fmt(): pass parameters more properly 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. --- diff --git a/daemon/lua/sandbox.lua.in b/daemon/lua/sandbox.lua.in index 4a513b258..8eebbfab7 100644 --- a/daemon/lua/sandbox.lua.in +++ b/daemon/lua/sandbox.lua.in @@ -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 diff --git a/lib/log.h b/lib/log.h index 402963204..f5be3da3b 100644 --- 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, ...);