diff options
author | Vsevolod Stakhov <vsevolod@rspamd.com> | 2023-12-04 15:01:09 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rspamd.com> | 2023-12-04 15:01:09 +0000 |
commit | 25e7d7ff17056d427e46a92d50a97355981c0e7f (patch) | |
tree | f23a566d0dd41af353b1bca7c6d752862a6d0605 /lualib | |
parent | be9845618c5456f930913114ff0ad4a54fb47d0a (diff) | |
download | rspamd-25e7d7ff17056d427e46a92d50a97355981c0e7f.tar.gz rspamd-25e7d7ff17056d427e46a92d50a97355981c0e7f.zip |
[Minor] Slightly improve logging
Diffstat (limited to 'lualib')
-rw-r--r-- | lualib/lua_redis.lua | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/lualib/lua_redis.lua b/lualib/lua_redis.lua index 3163b45c6..edaae9443 100644 --- a/lualib/lua_redis.lua +++ b/lualib/lua_redis.lua @@ -1207,9 +1207,9 @@ local function load_script_task(script, task, is_write) else opt.upstream:ok() logger.infox(task, - "uploaded redis script to %s with id %s, sha: %s", + "uploaded redis script to %s %s %s, sha: %s", opt.upstream:get_addr():to_string(true), - script.id, data) + script.filename and "from file" or "with id", script.filename or script.id, data) script.sha = data -- We assume that sha is the same on all servers end script.in_flight = script.in_flight - 1 @@ -1244,16 +1244,18 @@ local function load_script_taskless(script, cfg, ev_base, is_write) opt.is_write = is_write opt.callback = function(err, data) if err then - logger.errx(cfg, 'cannot upload script to %s: %s; registered from: %s:%s', + logger.errx(cfg, 'cannot upload script to %s: %s; registered from: %s:%s, filename: %s', opt.upstream:get_addr():to_string(true), - err, script.caller.short_src, script.caller.currentline) + err, script.caller.short_src, script.caller.currentline, script.filename) opt.upstream:fail() script.fatal_error = err else opt.upstream:ok() logger.infox(cfg, - "uploaded redis script to %s with id %s, sha: %s", - opt.upstream:get_addr():to_string(true), script.id, data) + "uploaded redis script to %s %s %s, sha: %s", + opt.upstream:get_addr():to_string(true), + script.filename and "from file" or "with id", script.filename or script.id, + data) script.sha = data -- We assume that sha is the same on all servers script.fatal_error = nil end @@ -1284,7 +1286,7 @@ local function load_redis_script(script, cfg, ev_base, _) end end -local function add_redis_script(script, redis_params, caller_level) +local function add_redis_script(script, redis_params, caller_level, maybe_filename) if not caller_level then caller_level = 2 end @@ -1296,7 +1298,8 @@ local function add_redis_script(script, redis_params, caller_level) redis_params = redis_params, script = script, waitq = {}, -- callbacks pending for script being loaded - id = #redis_scripts + 1 + id = #redis_scripts + 1, + filename = maybe_filename, } -- Register on load function @@ -1333,25 +1336,26 @@ local function load_redis_script_from_file(filename, redis_params, dir) if not dir then dir = rspamd_paths.LUALIBDIR end + local path = filename if filename:sub(1, 1) ~= package.config:sub(1, 1) then -- Relative path - filename = lua_util.join_path(dir, "redis_scripts", filename) + path = lua_util.join_path(dir, "redis_scripts", filename) end -- Read file contents - local file = io.open(filename, "r") + local file = io.open(path, "r") if not file then - rspamd_logger.errx("failed to open Redis script file: %s", filename) + rspamd_logger.errx("failed to open Redis script file: %s", path) return nil end local script = file:read("*all") if not script then - rspamd_logger.errx("failed to load Redis script file: %s", filename) + rspamd_logger.errx("failed to load Redis script file: %s", path) return nil end file:close() script = lua_util.strip_lua_comments(script) - return add_redis_script(script, redis_params, 3) + return add_redis_script(script, redis_params, 3, filename) end exports.load_redis_script_from_file = load_redis_script_from_file |