]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
doc: log() functions
authorLukáš Ježek <lukas.jezek@nic.cz>
Wed, 21 Jul 2021 11:31:24 +0000 (13:31 +0200)
committerTomas Krizek <tomas.krizek@nic.cz>
Thu, 29 Jul 2021 09:42:35 +0000 (11:42 +0200)
daemon/scripting.rst
modules/http/custom_services.rst

index 3a464605934680e0558e4a4846bac8f1c59355eb..5cc8a0453a2fc7dd72fa59f039393330df09b6c9 100644 (file)
@@ -320,11 +320,12 @@ anonymous function:
 
 .. code-block:: lua
 
+   local ffi = require('ffi')
    modules.load('stats')
 
    -- log statistics every second
    local stat_id = event.recurrent(1 * second, function(evid)
-        log(table_print(stats.list()))
+        log_info(ffi.C.LOG_GRP_STATISTICS, table_print(stats.list()))
    end)
 
    -- stop printing statistics after first minute
@@ -342,6 +343,7 @@ function, which provides persistent variable called ``previous``.
 
 .. code-block:: lua
 
+   local ffi = require('ffi')
    modules.load('stats')
 
    -- make a closure, encapsulating counter
@@ -353,7 +355,7 @@ function, which provides persistent variable called ``previous``.
            local total_increment = now['answer.total'] - previous['answer.total']
            local slow_increment = now['answer.slow'] - previous['answer.slow']
            if slow_increment / total_increment > 0.05 then
-               log('WARNING! More than 5 %% of queries was slow!')
+               log_warn(ffi.C.LOG_GRP_STATISTICS, 'WARNING! More than 5 %% of queries was slow!')
            end
            previous = now  -- store current value in closure
         end
index 4e60b03025896b711790f0712f22e7b576e71beb..09ba5ab4bc4b263617fcd092986cdca24eb82d9e 100644 (file)
@@ -99,7 +99,7 @@ the HTTP response code or send headers and body yourself.
                -- Get request method and deal with it properly
                local m = h:get(':method')
                local path = h:get(':path')
-               log('[service] method %s path %s', m, path)
+               log('method %s path %s', m, path)
                -- Return table, response code will be '200 OK'
                if m == 'GET' then
                        return {key = path, value = value}