From: Christian Roessner Date: Mon, 6 Mar 2017 12:11:44 +0000 (+0100) Subject: [Minor] Optimize savapi logging X-Git-Tag: 1.5.2~21^2 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=1d086a0f1d8540cb4572dc37f4ab271a46435411;p=rspamd.git [Minor] Optimize savapi logging --- diff --git a/src/plugins/lua/antivirus.lua b/src/plugins/lua/antivirus.lua index 07bfae1ec..417a93fb4 100644 --- a/src/plugins/lua/antivirus.lua +++ b/src/plugins/lua/antivirus.lua @@ -487,32 +487,26 @@ local function savapi_check(task, rule) local message_file = task:store_in_file(tonumber("0644", 8)) local function savapi_fin_cb(err, conn) - rspamd_logger.debugm(N, task, 'savapi_fin_cb called') if conn then conn:close() end end local function savapi_scan2_cb(err, data, conn) - rspamd_logger.debugm(N, task, 'savapi_scan2_cb called') local result = tostring(data) - rspamd_logger.debugm(N, task, "got reply: %s", result) + rspamd_logger.debugm(N, task, "%s: got reply: %s", rule['type'], result) if string.find(result, '200') or string.find(result, '210') then - -- clean message - rspamd_logger.debugm(N, task, 'clean message') if rule['log_clean'] then - rspamd_logger.infox(task, 'SAVAPI: message is clean') + rspamd_logger.infox(task, '%s: message is clean', rule['type']) end save_av_cache(task, rule, 'OK') elseif string.find(result, '310') then - -- infected message - rspamd_logger.debugm(N, task, 'infected message') -- Recursive result local parts = rspamd_str_split(result, ' <<< ') local vname = rspamd_str_split(parts[2], ';')[1]:match "^%s*(.-)%s*$" - rspamd_logger.infox(task, 'SAVAPI: virus found: %s', vname) + rspamd_logger.infox(task, '%s: virus found: %s', rule['type'], vname) yield_result(task, rule, vname) save_av_cache(task, rule, vname) end @@ -520,31 +514,26 @@ local function savapi_check(task, rule) end local function savapi_scan1_cb(err, conn) - rspamd_logger.debugm(N, task, 'savapi_scan1_cb called') conn:add_read(savapi_scan2_cb, '\n') end -- 100 PRODUCT:xyz local function savapi_greet2_cb(err, data, conn) local result = tostring(data) - rspamd_logger.debugm(N, task, 'savapi_greet2_cb called') - rspamd_logger.debugm(N, task, "got reply: %s", result) if string.find(result, '100 PRODUCT') then + rspamd_logger.debugm(N, task, "%s: scanning file: %s", rule['type'], message_file) conn:add_write(savapi_scan1_cb, {string.format('SCAN %s\n', message_file)}) else - rspamd_logger.errx(task, 'invalid product id %s', rule['product_id']) + rspamd_logger.errx(task, '%s: invalid product id %s', rule['type'], rule['product_id']) conn:add_write(savapi_fin_cb, 'QUIT\n') end end local function savapi_greet1_cb(err, conn) - rspamd_logger.debugm(N, task, 'savapi_greet1_cb called') conn:add_read(savapi_greet2_cb, '\n') end local function savapi_callback_init(err, data, conn) - rspamd_logger.debugm(N, task, 'savapi_callback_init called') - if err then if err == 'IO timeout' then if retransmits > 0 then @@ -571,7 +560,6 @@ local function savapi_check(task, rule) -- 100 SAVAPI:4.0 greeting if string.find(result, '100') then - rspamd_logger.debugm(N, task, "got reply: %s", result) conn:add_write(savapi_greet1_cb, {string.format('SET PRODUCT %s\n', rule['product_id'])}) end end