aboutsummaryrefslogtreecommitdiffstats
path: root/src/lua
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2016-05-05 09:26:43 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2016-05-05 09:26:43 +0100
commit839e4775b77c3b1fe256c640ab9920ebb6e51afb (patch)
tree90c748d277982dc2eb9889567330aebef72d4d66 /src/lua
parentd2b0976bc8b18897f02905329849583817997116 (diff)
downloadrspamd-839e4775b77c3b1fe256c640ab9920ebb6e51afb.tar.gz
rspamd-839e4775b77c3b1fe256c640ab9920ebb6e51afb.zip
[Feature] Improve logging lua types
Diffstat (limited to 'src/lua')
-rw-r--r--src/lua/lua_common.h11
-rw-r--r--src/lua/lua_logger.c11
2 files changed, 18 insertions, 4 deletions
diff --git a/src/lua/lua_common.h b/src/lua/lua_common.h
index c20d833ca..73be9e0c5 100644
--- a/src/lua/lua_common.h
+++ b/src/lua/lua_common.h
@@ -335,5 +335,16 @@ void lua_push_internet_address_list (lua_State *L, InternetAddressList *addrs);
* @return
*/
gboolean lua_push_internet_address (lua_State *L, InternetAddress *ia);
+
+/**
+ * Log lua object to string
+ * @param L
+ * @param pos
+ * @param outbuf
+ * @param len
+ * @return
+ */
+gsize lua_logger_out_type (lua_State *L, gint pos, gchar *outbuf,
+ gsize len);
#endif /* WITH_LUA */
#endif /* RSPAMD_LUA_H */
diff --git a/src/lua/lua_logger.c b/src/lua/lua_logger.c
index 125f0ff80..462838ba1 100644
--- a/src/lua/lua_logger.c
+++ b/src/lua/lua_logger.c
@@ -55,9 +55,6 @@ print(str)
-- Output: a=string, b=1.50000, c=1, d={[1] = aa, [2] = 1, [3] = bb} e={[key]=value, [key2]=1.0}
*/
-static gsize lua_logger_out_type (lua_State *L, gint pos, gchar *outbuf,
- gsize len);
-
/* Logger methods */
/***
* @function logger.err(msg)
@@ -404,7 +401,7 @@ lua_logger_out_table (lua_State *L, gint pos, gchar *outbuf, gsize len)
#undef MOVE_BUF
-static gsize
+gsize
lua_logger_out_type (lua_State *L, gint pos, gchar *outbuf, gsize len)
{
gint type;
@@ -432,6 +429,12 @@ lua_logger_out_type (lua_State *L, gint pos, gchar *outbuf, gsize len)
case LUA_TFUNCTION:
r = rspamd_snprintf (outbuf, len + 1, "function");
break;
+ case LUA_TNIL:
+ r = rspamd_snprintf (outbuf, len + 1, "nil");
+ break;
+ case LUA_TNONE:
+ r = rspamd_snprintf (outbuf, len + 1, "no value");
+ break;
default:
/* Try to push everything as string using tostring magic */
r = lua_logger_out_str (L, pos, outbuf, len);