From dbe4fcd08f8ccd2c27d4a5d4a8f8c784b9c0ec88 Mon Sep 17 00:00:00 2001 From: Vlad Patrascu Date: Thu, 22 Jun 2023 17:10:54 +0300 Subject: [PATCH] lua: fix duplicate logs to syslog (cherry picked from commit 949422a938ed12c5b5a820dc4af6de1c437b3798) --- modules/lua/doc/lua_admin.xml | 4 ---- modules/lua/doc/lua_api.xml | 7 ------- modules/lua/siplua.c | 2 -- modules/lua/siplua.h | 1 - modules/lua/sipluafunc.c | 21 ++------------------- modules/lua/sipstate.c | 10 ---------- 6 files changed, 2 insertions(+), 43 deletions(-) diff --git a/modules/lua/doc/lua_admin.xml b/modules/lua/doc/lua_admin.xml index 4705d689671..2abdf8499f1 100644 --- a/modules/lua/doc/lua_admin.xml +++ b/modules/lua/doc/lua_admin.xml @@ -140,10 +140,6 @@ modparam("lua", "luafilename", "/etc/opensips/opensips.lua") -
- lua_user_debug (int) - Disable by default -
Exported Functions diff --git a/modules/lua/doc/lua_api.xml b/modules/lua/doc/lua_api.xml index 6c34ea28729..a79444785b7 100644 --- a/modules/lua/doc/lua_api.xml +++ b/modules/lua/doc/lua_api.xml @@ -28,13 +28,6 @@
-
- setUserDebug - - Enable or disable the xlog feature. - Disabled, the xlog function has no effect. - -
WarnMissingFreeFixup diff --git a/modules/lua/siplua.c b/modules/lua/siplua.c index 713ccbd36b0..cfee75aa55a 100644 --- a/modules/lua/siplua.c +++ b/modules/lua/siplua.c @@ -29,7 +29,6 @@ #include "sipstate.h" char *luafilename = ""; -int lua_user_debug = 1; char *lua_allocator = "opensips"; int lua_auto_reload = 0; @@ -57,7 +56,6 @@ static const cmd_export_t cmds[] = { */ static const param_export_t params[] = { { "luafilename", STR_PARAM, &luafilename}, - { "lua_user_debug", INT_PARAM, &lua_user_debug}, { "lua_allocator", STR_PARAM, &lua_allocator}, { "lua_auto_reload", INT_PARAM, &lua_auto_reload}, { 0, 0, 0 } diff --git a/modules/lua/siplua.h b/modules/lua/siplua.h index 661536db0e0..78408df94b8 100644 --- a/modules/lua/siplua.h +++ b/modules/lua/siplua.h @@ -20,7 +20,6 @@ #ifndef SIPLUA_H_ # define SIPLUA_H_ -extern int lua_user_debug; extern int lua_auto_reload; extern struct sl_binds slb; diff --git a/modules/lua/sipluafunc.c b/modules/lua/sipluafunc.c index 77e1576831b..4a90ea461e5 100644 --- a/modules/lua/sipluafunc.c +++ b/modules/lua/sipluafunc.c @@ -50,35 +50,18 @@ void siplua_log(int lev, const char *format, ...) { va_list ap; char *ret; - int priority; int rc; if (!format) return; - if (!(is_printable(lev) | lua_user_debug)) - return; + va_start(ap, format); rc = vasprintf(&ret, format, ap); va_end(ap); if (rc < 0) return; LM_GEN1(lev, "siplua: %s", ret); - if (lua_user_debug) - { - switch (lev) - { - case L_ALERT: priority = LOG_ALERT; break; - case L_CRIT: priority = LOG_CRIT; break; - case L_ERR: priority = LOG_ERR; break; - case L_WARN: priority = LOG_WARNING; break; - case L_NOTICE: priority = LOG_NOTICE; break; - case L_INFO: priority = LOG_INFO; break; - case L_DBG: priority = LOG_DEBUG; break; - default: /* should not happen, no execution path permits it */ - priority = LOG_ERR; - } - syslog(LOG_USER | priority, "siplua: %s", ret); - } + free(ret); } diff --git a/modules/lua/sipstate.c b/modules/lua/sipstate.c index fb98c48fc87..c101621ad34 100644 --- a/modules/lua/sipstate.c +++ b/modules/lua/sipstate.c @@ -186,15 +186,6 @@ static int l_sipstate_notice(lua_State *L) return 0; } -static int l_sipstate_setUserDebug(lua_State *L) -{ - int n; - - n = luaL_checkinteger(L, 1); - lua_user_debug = n; - return 0; -} - static int l_sipstate_getpid(lua_State *L) { int pid; @@ -303,7 +294,6 @@ static const struct luaL_Reg siplua_state_mylib [] = {"xdbg", l_sipstate_xdbg}, {"print", l_sipstate_print}, {"notice", l_sipstate_notice}, - {"setUserDebug", l_sipstate_setUserDebug}, {"getpid", l_sipstate_getpid}, {"getmem", l_sipstate_getmem}, {"getmeminfo", l_sipstate_getpkginfo},