From: Vsevolod Stakhov Date: Thu, 5 May 2016 08:26:43 +0000 (+0100) Subject: [Feature] Improve logging lua types X-Git-Tag: 1.3.0~548 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=839e4775b77c3b1fe256c640ab9920ebb6e51afb;p=thirdparty%2Frspamd.git [Feature] Improve logging lua types --- diff --git a/src/lua/lua_common.h b/src/lua/lua_common.h index c20d833ca3..73be9e0c51 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 125f0ff80e..462838ba1f 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);