From 1afc6d0cfcb81bf2c16ab3694794d8901f4e62ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20Mass=C3=A9?= Date: Tue, 29 Aug 2017 17:25:01 +0200 Subject: [PATCH] fix a bug with the periodic_flush param --- verbose.lua | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/verbose.lua b/verbose.lua index 62fe187..eae9359 100644 --- a/verbose.lua +++ b/verbose.lua @@ -55,14 +55,22 @@ end function _M:init_worker() ngx.log(ngx.INFO, "Initializing the underlying logger") if not logger.initted() then - local ok, err = logger.init{ + -- default parameters + local params = { host = host, port = port, sock_type = proto, flush_limit = flush_limit, - drop_limit = drop_limit, - periodic_flush = periodic_flush + drop_limit = drop_limit } + + -- periodic_flush == 0 means 'disable this feature' + if periodic_flush > 0 then + params["periodic_flush"] = periodic_flush + end + + -- initialize the logger + local ok, err = logger.init(params) if not ok then ngx.log(ngx.ERR, "failed to initialize the logger: ", err) end @@ -77,7 +85,7 @@ function do_log(payload) -- the Lua variable "msg" -- -- do not forget the \n in order to have one request per line on the syslog server - -- + -- local bytes, err = logger.log(payload .. "\n") if err then ngx.log(ngx.ERR, "failed to log message: ", err)