summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/lua/lua_logger.c9
-rw-r--r--test/lua/unit/logger.lua1
2 files changed, 6 insertions, 4 deletions
diff --git a/src/lua/lua_logger.c b/src/lua/lua_logger.c
index ab1f49e4a..d82237f55 100644
--- a/src/lua/lua_logger.c
+++ b/src/lua/lua_logger.c
@@ -47,8 +47,10 @@ local e = {
}
-- New extended interface
+-- %<number> means numeric arguments and %s means the next argument
+-- for example %1, %2, %s: %s would mean the third argument
-rspamd_logger.infox('a=%1, b=%2, c=%3, d=%4, e=%5', a, b, c, d, e)
+rspamd_logger.infox('a=%1, b=%2, c=%3, d=%4, e=%s', a, b, c, d, e)
-- Output: a=string, b=1.50000, c=1, d={[1] = aa, [2] = 1, [3] = bb} e={[key]=value, [key2]=1.0}
-- Legacy interface (can handle merely strings)
@@ -449,7 +451,6 @@ lua_logger_logx (lua_State *L, GLogLevelFlags level, gboolean is_string)
lua_pushstring (L, "__index");
lua_gettable (L, -2);
- lua_istable (L, -1);
lua_pushstring (L, "class");
lua_gettable (L, -2);
@@ -493,7 +494,7 @@ lua_logger_logx (lua_State *L, GLogLevelFlags level, gboolean is_string)
s = lua_tostring (L, fmt_pos);
c = s;
- cur_arg = fmt_pos + 1;
+ cur_arg = fmt_pos;
if (s == NULL) {
return 0;
@@ -531,7 +532,7 @@ lua_logger_logx (lua_State *L, GLogLevelFlags level, gboolean is_string)
arg_num = strtoul (c, NULL, 10);
arg_num += fmt_pos - 1;
/* Update the current argument */
- cur_arg = arg_num + 1;
+ cur_arg = arg_num;
}
else {
/* We have non numeric argument, e.g. %s */
diff --git a/test/lua/unit/logger.lua b/test/lua/unit/logger.lua
index e382ab7e4..29ff4c891 100644
--- a/test/lua/unit/logger.lua
+++ b/test/lua/unit/logger.lua
@@ -11,6 +11,7 @@ context("Logger unit tests", function()
{'%1', '{[1] = 1, [2] = test}', {1, 'test'}},
{'%1', '{[k1] = 1, [k2] = test}', {k1=1, k2='test'}},
{'%1', '{[1] = 1, [2] = 2.100000, [k2] = test}', {1, 2.1, k2='test'}},
+ {'%s', 'true', true},
}
for _,c in ipairs(cases) do