[sr-dev] git:master:92421ec9: app_lua: new module parameter - log_mode

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[sr-dev] git:master:92421ec9: app_lua: new module parameter - log_mode

Daniel-Constantin Mierla
Module: kamailio
Branch: master
Commit: 92421ec9e377d5422b686554dca738e3a0492435
URL: https://github.com/kamailio/kamailio/commit/92421ec9e377d5422b686554dca738e3a0492435

Author: Daniel-Constantin Mierla <[hidden email]>
Committer: Daniel-Constantin Mierla <[hidden email]>
Date: 2018-08-20T14:47:48+02:00

app_lua: new module parameter - log_mode

- control what is printed in log messages by module
- if bit 1 is set, the it prints the KEMI exports

---

Modified: src/modules/app_lua/app_lua_mod.c
Modified: src/modules/app_lua/app_lua_sr.c

---

Diff:  https://github.com/kamailio/kamailio/commit/92421ec9e377d5422b686554dca738e3a0492435.diff
Patch: https://github.com/kamailio/kamailio/commit/92421ec9e377d5422b686554dca738e3a0492435.patch

---

diff --git a/src/modules/app_lua/app_lua_mod.c b/src/modules/app_lua/app_lua_mod.c
index 362a9bc6b6..8450610140 100644
--- a/src/modules/app_lua/app_lua_mod.c
+++ b/src/modules/app_lua/app_lua_mod.c
@@ -65,10 +65,13 @@ int app_lua_load_param(modparam_t type, void *val);
 int app_lua_register_param(modparam_t type, void *val);
 int app_lua_reload_param(modparam_t type, void *val);
 
+int _ksr_app_lua_log_mode = 0;
+
 static param_export_t params[]={
  {"load",     PARAM_STRING|USE_FUNC_PARAM, (void*)app_lua_load_param},
  {"register", PARAM_STRING|USE_FUNC_PARAM, (void*)app_lua_register_param},
  {"reload",   INT_PARAM|USE_FUNC_PARAM, (void*)app_lua_reload_param},
+ {"log_mode", PARAM_INT, &_ksr_app_lua_log_mode},
  {0, 0, 0}
 };
 
diff --git a/src/modules/app_lua/app_lua_sr.c b/src/modules/app_lua/app_lua_sr.c
index a72e657279..4414bd83a2 100644
--- a/src/modules/app_lua/app_lua_sr.c
+++ b/src/modules/app_lua/app_lua_sr.c
@@ -44,6 +44,10 @@
 #include "app_lua_kemi_export.h"
 #include "app_lua_sr.h"
 
+#define KSR_APP_LUA_LOG_EXPORTS (1<<0)
+
+extern int _ksr_app_lua_log_mode;
+
 /**
  *
  */
@@ -2029,7 +2033,9 @@ void lua_sr_kemi_register_libs(lua_State *L)
  }
 
  for(i=0; emods[0].kexp[i].func!=NULL; i++) {
- LM_DBG("exporting KSR.%s(...)\n", emods[0].kexp[i].fname.s);
+ if(_ksr_app_lua_log_mode & KSR_APP_LUA_LOG_EXPORTS) {
+ LM_DBG("exporting KSR.%s(...)\n", emods[0].kexp[i].fname.s);
+ }
  _sr_crt_KSRMethods[i].name = emods[0].kexp[i].fname.s;
  _sr_crt_KSRMethods[i].func =
  sr_kemi_lua_export_associate(&emods[0].kexp[i]);
@@ -2055,8 +2061,10 @@ void lua_sr_kemi_register_libs(lua_State *L)
  _sr_crt_KSRMethods = _sr_KSRMethods + n;
  snprintf(mname, 128, "KSR.%s", emods[k].kexp[0].mname.s);
  for(i=0; emods[k].kexp[i].func!=NULL; i++) {
- LM_DBG("exporting %s.%s(...)\n", mname,
- emods[k].kexp[i].fname.s);
+ if(_ksr_app_lua_log_mode & KSR_APP_LUA_LOG_EXPORTS) {
+ LM_DBG("exporting %s.%s(...)\n", mname,
+ emods[k].kexp[i].fname.s);
+ }
  _sr_crt_KSRMethods[i].name = emods[k].kexp[i].fname.s;
  _sr_crt_KSRMethods[i].func =
  sr_kemi_lua_export_associate(&emods[k].kexp[i]);
@@ -2073,8 +2081,10 @@ void lua_sr_kemi_register_libs(lua_State *L)
  exit(-1);
  }
  luaL_openlib(L, mname, _sr_crt_KSRMethods, 0);
- LM_DBG("initializing kemi sub-module: %s (%s) (%d/%d/%d)\n", mname,
- emods[k].kexp[0].mname.s, i, k, n);
+ if(_ksr_app_lua_log_mode & KSR_APP_LUA_LOG_EXPORTS) {
+ LM_DBG("initializing kemi sub-module: %s (%s) (%d/%d/%d)\n",
+ mname, emods[k].kexp[0].mname.s, i, k, n);
+ }
  }
  }
  LM_DBG("module 'KSR' has been initialized (%d/%d)\n", emods_size, n);


_______________________________________________
Kamailio (SER) - Development Mailing List
[hidden email]
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev