]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
logging: use LOG_GRP_HTTP for http lua module
authorTomas Krizek <tomas.krizek@nic.cz>
Thu, 8 Jul 2021 15:07:10 +0000 (17:07 +0200)
committerTomas Krizek <tomas.krizek@nic.cz>
Thu, 29 Jul 2021 09:42:33 +0000 (11:42 +0200)
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.

daemon/lua/kres-gen-29.lua
lib/log.c
lib/log.h
modules/http/http.lua.in
modules/http/http_tls_cert.lua

index 4c1f368826e20961b4415e5ce771c6bdbbd46780..a60e115bfc699f730e315ce2c10ce4c6099144e9 100644 (file)
@@ -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;
index bb2a06055c267008c663ab50d7b5ce3cb444ad85..dbc8fe35135bf2eb3947848ddc1156d2525241ee 100644 (file)
--- 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 },
 };
index 0062e045dab93b25514f817091dec61c891c5a18..3ecaad492e003f82906295eb7314416ba36d41af 100644 (file)
--- 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
index 56baab1718e9022301b68da77332002d5990f378..339afbf73a212d6ea12a9f2128cdeb8c223ff37f 100644 (file)
@@ -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
 
index ac1dcb3ff2e56199b176e91005f7a381aa7e93a1..e25bed59ba9114a788c49be36bbcc001e8ce6283 100644 (file)
@@ -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