From: Tomas Krizek Date: Thu, 8 Jul 2021 15:07:10 +0000 (+0200) Subject: logging: use LOG_GRP_HTTP for http lua module X-Git-Tag: v5.4.0~2^2~32 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9509a9810b1e9070aa7dff383c28ae7991f11215;p=thirdparty%2Fknot-resolver.git logging: use LOG_GRP_HTTP for http lua module It's better to use separate log group, to separate between logs that come from the lua module vs native C implementation. It is also more descriptive, since http modules is used for other stuff besides its deprecated DoH. --- diff --git a/daemon/lua/kres-gen-29.lua b/daemon/lua/kres-gen-29.lua index 4c1f36882..a60e115bf 100644 --- a/daemon/lua/kres-gen-29.lua +++ b/daemon/lua/kres-gen-29.lua @@ -308,7 +308,7 @@ struct kr_server_selection { }; typedef unsigned long log_groups_t; typedef int log_level_t; -enum kr_log_groups_type {LOG_GRP_SYSTEM = 1, LOG_GRP_CACHE, LOG_GRP_IO, LOG_GRP_NETWORK, LOG_GRP_TA, LOG_GRP_TLS, LOG_GRP_GNUTLS, LOG_GRP_TLSCLIENT, LOG_GRP_XDP, LOG_GRP_ZIMPORT, LOG_GRP_ZSCANNER, LOG_GRP_DOH, LOG_GRP_DNSSEC, LOG_GRP_HINT, LOG_GRP_PLAN, LOG_GRP_ITERATOR, LOG_GRP_VALIDATOR, LOG_GRP_RESOLVER, LOG_GRP_SELECTION, LOG_GRP_ZCUT, LOG_GRP_COOKIES, LOG_GRP_STATISTICS, LOG_GRP_REBIND, LOG_GRP_WORKER, LOG_GRP_POLICY, LOG_GRP_TASENTINEL, LOG_GRP_TASIGNALING, LOG_GRP_TAUPDATE, LOG_GRP_DAF, LOG_GRP_DETECTTIMEJUMP, LOG_GRP_DETECTTIMESKEW, LOG_GRP_GRAPHITE, LOG_GRP_PREFILL, LOG_GRP_PRIMING, LOG_GRP_SRVSTALE, LOG_GRP_WATCHDOG, LOG_GRP_NSID, LOG_GRP_DNSTAP, LOG_GRP_TESTS, LOG_GRP_DOTAUTH, LOG_GRP_DEVEL}; +enum kr_log_groups_type {LOG_GRP_SYSTEM = 1, LOG_GRP_CACHE, LOG_GRP_IO, LOG_GRP_NETWORK, LOG_GRP_TA, LOG_GRP_TLS, LOG_GRP_GNUTLS, LOG_GRP_TLSCLIENT, LOG_GRP_XDP, LOG_GRP_ZIMPORT, LOG_GRP_ZSCANNER, LOG_GRP_DOH, LOG_GRP_DNSSEC, LOG_GRP_HINT, LOG_GRP_PLAN, LOG_GRP_ITERATOR, LOG_GRP_VALIDATOR, LOG_GRP_RESOLVER, LOG_GRP_SELECTION, LOG_GRP_ZCUT, LOG_GRP_COOKIES, LOG_GRP_STATISTICS, LOG_GRP_REBIND, LOG_GRP_WORKER, LOG_GRP_POLICY, LOG_GRP_TASENTINEL, LOG_GRP_TASIGNALING, LOG_GRP_TAUPDATE, LOG_GRP_DAF, LOG_GRP_DETECTTIMEJUMP, LOG_GRP_DETECTTIMESKEW, LOG_GRP_GRAPHITE, LOG_GRP_PREFILL, LOG_GRP_PRIMING, LOG_GRP_SRVSTALE, LOG_GRP_WATCHDOG, LOG_GRP_NSID, LOG_GRP_DNSTAP, LOG_GRP_TESTS, LOG_GRP_DOTAUTH, LOG_GRP_HTTP, LOG_GRP_DEVEL}; kr_layer_t kr_layer_t_static; _Bool kr_dbg_assertion_abort; diff --git a/lib/log.c b/lib/log.c index bb2a06055..dbc8fe351 100644 --- a/lib/log.c +++ b/lib/log.c @@ -65,6 +65,7 @@ log_group_names_t log_group_names[] = { GRP_NAME_ITEM(LOG_GRP_DNSTAP), GRP_NAME_ITEM(LOG_GRP_TESTS), GRP_NAME_ITEM(LOG_GRP_DOTAUTH), + GRP_NAME_ITEM(LOG_GRP_HTTP), GRP_NAME_ITEM(LOG_GRP_DEVEL), { NULL, -1 }, }; diff --git a/lib/log.h b/lib/log.h index 0062e045d..3ecaad492 100644 --- a/lib/log.h +++ b/lib/log.h @@ -70,6 +70,7 @@ enum kr_log_groups_type { LOG_GRP_DNSTAP, LOG_GRP_TESTS, LOG_GRP_DOTAUTH, + LOG_GRP_HTTP, /* ^^ Add new log groups above ^^. */ LOG_GRP_DEVEL, /* Must be last entry in enum! */ }; @@ -115,6 +116,7 @@ enum kr_log_groups_type { #define LOG_GRP_DNSTAP_TAG "dnstap" #define LOG_GRP_TESTS_TAG "tests" #define LOG_GRP_DOTAUTH_TAG "dotaut" +#define LOG_GRP_HTTP_TAG "http" #define LOG_GRP_DEVEL_TAG "devel" KR_EXPORT diff --git a/modules/http/http.lua.in b/modules/http/http.lua.in index 56baab171..339afbf73 100644 --- a/modules/http/http.lua.in +++ b/modules/http/http.lua.in @@ -43,7 +43,7 @@ M.configs._builtin._all.onerror = function(myserver, context, op, err, errno) -- if err then msg = msg .. ': ' .. tostring(err) end - log_info(ffi.C.LOG_GRP_DOH, msg) + log_info(ffi.C.LOG_GRP_HTTP, msg) end -- M.config() without explicit "kind" modifies this @@ -224,7 +224,7 @@ local function route(endpoints) -- Upgrade connection to WebSocket local ws = http_websocket.new_from_stream(stream, h) if ws then - log_info(ffi.C.LOG_GRP_DOH, '%s %s HTTP/%s web socket open', + log_info(ffi.C.LOG_GRP_HTTP, '%s %s HTTP/%s web socket open', m, path, tostring(connection.version)) assert(ws:accept { protocols = {'json'} }) -- Continue streaming results to client @@ -234,14 +234,14 @@ local function route(endpoints) cb(h, ws) end ws:close() - log_info(ffi.C.LOG_GRP_DOH, '%s %s HTTP/%s web socket closed', + log_info(ffi.C.LOG_GRP_HTTP, '%s %s HTTP/%s web socket closed', m, path, tostring(connection.version)) return else local ok, err, reason = http_util.yieldable_pcall(serve, endpoints, h, stream) if not ok or err then err = err or '500' - log_info(ffi.C.LOG_GRP_DOH, '%s %s HTTTP/%s %s %s', + log_info(ffi.C.LOG_GRP_HTTP, '%s %s HTTTP/%s %s %s', m, path, tostring(connection.version), err, reason or '') -- Method is not supported local hsend = http_headers.new() @@ -253,7 +253,7 @@ local function route(endpoints) assert(stream:write_headers(hsend, true)) end else - log_info(ffi.C.LOG_GRP_DOH, '%s %s HTTP/%s 200', + log_info(ffi.C.LOG_GRP_HTTP, '%s %s HTTP/%s 200', m, path, tostring(connection.version)) end diff --git a/modules/http/http_tls_cert.lua b/modules/http/http_tls_cert.lua index ac1dcb3ff..e25bed59b 100644 --- a/modules/http/http_tls_cert.lua +++ b/modules/http/http_tls_cert.lua @@ -72,7 +72,7 @@ function tls_cert.ephemeral_state_maintain(ephem_state, certfile, keyfile) s.server.ctx = ephem_state.ctx s.config.ctx = ephem_state.ctx -- not required, but let's keep it synchonized end - log_info(ffi.C.LOG_GRP_DOH, 'created new ephemeral TLS certificate') + log_info(ffi.C.LOG_GRP_HTTP, 'created new ephemeral TLS certificate') local _, expiry_stamp = certs[1]:getLifetime() local wait_msec = 1000 * math.max(1, expiry_stamp - os.time() - 3 * 24 * 3600) if not ephem_state.timer_id then @@ -174,8 +174,8 @@ function tls_cert.new_tls_context(certs, key) assert(ctx:setCertificateChain(chain)) elseif not warned_old_luaossl then -- old luaossl version -> only final cert sent to clients - log_warn(ffi.C.LOG_GRP_DOH, - 'Warning: need luaossl >= 20181207 to support sending intermediary certificate to clients') + log_warn(ffi.C.LOG_GRP_HTTP, + 'need luaossl >= 20181207 to support sending intermediary certificate to clients') warned_old_luaossl = true end return ctx