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 /src/lua/lua_common.c | |
parent | 843a6e1bcd0bc3a50079ecccf7685f590c678004 (diff) | |
download | rspamd-d055682d58ee60a67cb4efcb7448309935fd50db.tar.gz rspamd-d055682d58ee60a67cb4efcb7448309935fd50db.zip |
[Minor] Improve logging
Diffstat (limited to 'src/lua/lua_common.c')
-rw-r--r-- | src/lua/lua_common.c | 17 |
1 files changed, 16 insertions, 1 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); |