diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2019-11-26 16:30:34 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2019-11-26 16:30:34 +0000 |
commit | d055682d58ee60a67cb4efcb7448309935fd50db (patch) | |
tree | 6829f4932b3addd2f76c645e3ebaf0545aa32e26 | |
parent | 843a6e1bcd0bc3a50079ecccf7685f590c678004 (diff) | |
download | rspamd-d055682d58ee60a67cb4efcb7448309935fd50db.tar.gz rspamd-d055682d58ee60a67cb4efcb7448309935fd50db.zip |
[Minor] Improve logging
-rw-r--r-- | src/lua/lua_common.c | 17 | ||||
-rw-r--r-- | src/lua/lua_text.c | 10 |
2 files changed, 24 insertions, 3 deletions
diff --git a/src/lua/lua_common.c b/src/lua/lua_common.c index 45ca2c97e..f5cd3b853 100644 --- a/src/lua/lua_common.c +++ b/src/lua/lua_common.c @@ -2112,11 +2112,14 @@ gboolean rspamd_lua_require_function (lua_State *L, const gchar *modname, const gchar *funcname) { - gint table_pos; + gint table_pos, err_pos; + lua_pushcfunction (L, &rspamd_lua_traceback); + err_pos = lua_gettop (L); lua_getglobal (L, "require"); if (lua_isnil (L, -1)) { + lua_remove (L, err_pos); lua_pop (L, 1); return FALSE; @@ -2126,13 +2129,21 @@ rspamd_lua_require_function (lua_State *L, const gchar *modname, /* Now try to call */ if (lua_pcall (L, 1, 1, 0) != 0) { + lua_remove (L, err_pos); + msg_warn ("require of %s.%s failed: %s", modname, + funcname, lua_tostring (L, -1)); lua_pop (L, 1); return FALSE; } + lua_remove (L, err_pos); + /* Now we should have a table with results */ if (!lua_istable (L, -1)) { + msg_warn ("require of %s.%s failed: not a table but %s", modname, + funcname, lua_typename (L, lua_type (L, -1))); + lua_pop (L, 1); return FALSE; @@ -2148,6 +2159,10 @@ rspamd_lua_require_function (lua_State *L, const gchar *modname, return TRUE; } + else { + msg_warn ("require of %s.%s failed: not a function but %s", modname, + funcname, lua_typename (L, lua_type (L, -1))); + } lua_pop (L, 2); diff --git a/src/lua/lua_text.c b/src/lua/lua_text.c index 09d9b88c1..55dcb8a88 100644 --- a/src/lua/lua_text.c +++ b/src/lua/lua_text.c @@ -355,7 +355,7 @@ lua_text_span (lua_State *L) { LUA_TRACE_POINT; struct rspamd_lua_text *t = lua_check_text (L, 1); - gint start = lua_tointeger (L, 2), len = -1; + gint64 start = lua_tointeger (L, 2), len = -1; if (t && start >= 1 && start <= t->len) { if (lua_isnumber (L, 3)) { @@ -372,7 +372,13 @@ lua_text_span (lua_State *L) lua_new_text (L, t->start + (start - 1), len, FALSE); } else { - return luaL_error (L, "invalid arguments"); + if (!t) { + return luaL_error (L, "invalid arguments, text required"); + } + else { + return luaL_error (L, "invalid arguments: start offset %d " + "is larger than text len %d", (int)start, (int)t->len); + } } return 1; |