From 9070cf78707c4bc77769148f4d50141da484c2c8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Luk=C3=A1=C5=A1=20Je=C5=BEek?= Date: Wed, 21 Jul 2021 13:31:24 +0200 Subject: [PATCH] doc: log() functions --- daemon/scripting.rst | 6 ++++-- modules/http/custom_services.rst | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/daemon/scripting.rst b/daemon/scripting.rst index 3a4646059..5cc8a0453 100644 --- a/daemon/scripting.rst +++ b/daemon/scripting.rst @@ -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 diff --git a/modules/http/custom_services.rst b/modules/http/custom_services.rst index 4e60b0302..09ba5ab4b 100644 --- a/modules/http/custom_services.rst +++ b/modules/http/custom_services.rst @@ -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} -- 2.47.3