]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
[Minor] Allow to get a trace function
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 9 Aug 2018 13:58:45 +0000 (14:58 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 9 Aug 2018 14:27:32 +0000 (15:27 +0100)
src/lua/lua_common.c

index 4faff86650965f1a53d9fc30fde449078e6549b4..7d9e525bb43f4d9d45d79a241bedbe0429f45e9e 100644 (file)
@@ -688,6 +688,21 @@ rspamd_lua_set_globals (struct rspamd_config *cfg, lua_State *L,
        lua_settop (L, orig_top);
 }
 
+#ifdef WITH_LUA_TRACE
+static gint
+lua_push_trace_data (lua_State *L)
+{
+       if (lua_traces) {
+               ucl_object_push_lua (L, lua_traces, true);
+       }
+       else {
+               lua_pushnil (L);
+       }
+
+       return 1;
+}
+#endif
+
 lua_State *
 rspamd_lua_init ()
 {
@@ -783,6 +798,11 @@ rspamd_lua_init ()
 #undef ADD_TABLE
        lua_setglobal (L, rspamd_modules_state_global);
 
+#ifdef WITH_LUA_TRACE
+       lua_pushcfunction (L, lua_push_trace_data);
+       lua_setglobal (L, "get_traces");
+#endif
+
        return L;
 }