From: Lukáš Ježek Date: Wed, 21 Jul 2021 10:50:04 +0000 (+0200) Subject: etc/config: Remove log functions X-Git-Tag: v5.4.0~2^2~21 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=79df69878cbfb5c586805adfd87aa9e0424a2bd5;p=thirdparty%2Fknot-resolver.git etc/config: Remove log functions --- diff --git a/etc/config/config.docker b/etc/config/config.docker index f036fd55f..4805ae32b 100644 --- a/etc/config/config.docker +++ b/etc/config/config.docker @@ -6,6 +6,8 @@ print('Knot Resolver ' .. package_version()) -- Smaller cache size cache.size = 10 * MB +local ffi = require('ffi') + function interactive_mode() -- Listen on all interfaces (localhost would not work in Docker) net.listen('0.0.0.0', 53, { kind = 'dns' }) @@ -62,7 +64,7 @@ function debug_mode(qname, qtype) -- ultra verbose log verbose(true) policy.add(policy.all(policy.DEBUG_ALWAYS)) - log('INFO: starting DNS query for %s %s', qname, kres.tostring.type[qtype]) + log_debug(ffi.C.LOG_GRP_RESOLVER, 'starting DNS query for %s %s', qname, kres.tostring.type[qtype]) local starttime = cqueues.monotime() resolve({ name = qname, @@ -74,7 +76,7 @@ function debug_mode(qname, qtype) event.after(1, -- milisecond function() local endtime = cqueues.monotime() - log('\nrequest finished in %f ms', (endtime - starttime) * 1000) + log_debug(ffi.C.LOG_GRP_RESOLVER, '\nrequest finished in %f ms', (endtime - starttime) * 1000) os.exit() end) end @@ -87,7 +89,7 @@ local qtype = os.getenv('QTYPE') if qname and qtype then qtypenum = kres.type[qtype] if not qtypenum then - log('ERROR: unsupported query type "%s", use TYPE12345 notation', qtype) + log_error(ffi.C.LOG_GRP_RESOLVER, 'ERROR: unsupported query type "%s", use TYPE12345 notation', qtype) os.exit() end debug_mode(qname, qtypenum) diff --git a/etc/config/config.isp b/etc/config/config.isp index 3dc3e7f0e..d4e2f9af9 100644 --- a/etc/config/config.isp +++ b/etc/config/config.isp @@ -20,9 +20,11 @@ modules = { 'stats' } +local ffi = require('ffi') + -- 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 @@ -42,7 +44,7 @@ function speed_monitor() local slow_increment = now['answer.slow'] - previous['answer.slow'] -- if percentage of slow answers is bigger than 5%, print warning 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 end