[sr-dev] git:master:86d0aaff: debugger: added cfgtrace_format parameter

Daniel-Constantin Mierla miconda at gmail.com
Thu Jul 29 13:34:30 CEST 2021


Module: kamailio
Branch: master
Commit: 86d0aaffd6c86c7c78e40b1e40ba37c17db44b22
URL: https://github.com/kamailio/kamailio/commit/86d0aaffd6c86c7c78e40b1e40ba37c17db44b22

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2021-07-29T13:00:09+02:00

debugger: added cfgtrace_format parameter

- control what is printed in the cfgtrace log message (e.g., do not
print config file path)

---

Modified: src/modules/debugger/debugger_api.c
Modified: src/modules/debugger/debugger_mod.c
Modified: src/modules/debugger/doc/debugger_admin.xml

---

Diff:  https://github.com/kamailio/kamailio/commit/86d0aaffd6c86c7c78e40b1e40ba37c17db44b22.diff
Patch: https://github.com/kamailio/kamailio/commit/86d0aaffd6c86c7c78e40b1e40ba37c17db44b22.patch

---

diff --git a/src/modules/debugger/debugger_api.c b/src/modules/debugger/debugger_api.c
index e9dd4c8fd7..dce2fbb19c 100644
--- a/src/modules/debugger/debugger_api.c
+++ b/src/modules/debugger/debugger_api.c
@@ -149,6 +149,13 @@ str *dbg_get_cmd_name(int t)
  */
 int _dbg_cfgtrace = 0;
 
+#define DBG_CFGTRACE_NOCFGFILE (1<<0)
+/**
+ *
+ */
+int _dbg_cfgtrace_format = 0;
+
+
 /**
  *
  */
@@ -359,13 +366,23 @@ int dbg_cfg_trace(sr_event_param_t *evp)
 	{
 		if(is_printable(_dbg_cfgtrace_level))
 		{
-			LOG_FL(_dbg_cfgtrace_facility, _dbg_cfgtrace_level,
-					_dbg_cfgtrace_lname, _dbg_cfgtrace_prefix,
-					"%s=[%s] c=[%s] l=%d a=%d n=%.*s\n",
-					get_current_route_type_name(), ZSW(a->rname),
-					ZSW(a->cfile), a->cline,
-					a->type, an->len, ZSW(an->s)
-				);
+			if(unlikely(_dbg_cfgtrace_format & DBG_CFGTRACE_NOCFGFILE)) {
+				LOG_FL(_dbg_cfgtrace_facility, _dbg_cfgtrace_level,
+						_dbg_cfgtrace_lname, _dbg_cfgtrace_prefix,
+						"%s=[%s] l=%d a=%d n=%.*s\n",
+						get_current_route_type_name(), ZSW(a->rname),
+						a->cline,
+						a->type, an->len, ZSW(an->s)
+					);
+			} else {
+				LOG_FL(_dbg_cfgtrace_facility, _dbg_cfgtrace_level,
+						_dbg_cfgtrace_lname, _dbg_cfgtrace_prefix,
+						"%s=[%s] c=[%s] l=%d a=%d n=%.*s\n",
+						get_current_route_type_name(), ZSW(a->rname),
+						ZSW(a->cfile), a->cline,
+						a->type, an->len, ZSW(an->s)
+					);
+			}
 		}
 	}
 	if(_dbg_pid_list[process_no].set&DBG_CFGTEST_ON)
diff --git a/src/modules/debugger/debugger_mod.c b/src/modules/debugger/debugger_mod.c
index 5ea494f0c4..3c35a5b033 100644
--- a/src/modules/debugger/debugger_mod.c
+++ b/src/modules/debugger/debugger_mod.c
@@ -62,6 +62,7 @@ extern char* dump_lump_list(struct lump *list, int s_offset, char *s_buf);
 
 /* parameters */
 extern int _dbg_cfgtrace;
+extern int _dbg_cfgtrace_format;
 extern int _dbg_cfgpkgcheck;
 extern int _dbg_breakpoint;
 extern int _dbg_cfgtrace_level;
@@ -100,6 +101,7 @@ static cmd_export_t cmds[]={
 
 static param_export_t params[]={
 	{"cfgtrace",          INT_PARAM, &_dbg_cfgtrace},
+	{"cfgtrace_format",   INT_PARAM, &_dbg_cfgtrace_format},
 	{"breakpoint",        INT_PARAM, &_dbg_breakpoint},
 	{"log_level",         INT_PARAM, &_dbg_cfgtrace_level},
 	{"log_facility",      PARAM_STRING, &_dbg_cfgtrace_facility_str},
diff --git a/src/modules/debugger/doc/debugger_admin.xml b/src/modules/debugger/doc/debugger_admin.xml
index 5757381a6d..9f39883bdc 100644
--- a/src/modules/debugger/doc/debugger_admin.xml
+++ b/src/modules/debugger/doc/debugger_admin.xml
@@ -101,6 +101,29 @@ modparam("debugger", "cfgtrace", 1)
 	    </example>
 	</section>
 
+	<section id="dbg.p.cfgtrace_format">
+	    <title><varname>cfgtrace_format</varname> (int)</title>
+	    <para>
+			Control what is printer in the cfgtrace log message. If it is set
+			to 1, then the configuration file path is not printed, making
+			the log messages shorter when not including other configuration
+			files in the main one.
+	    </para>
+	    <para>
+		<emphasis>
+		    Default value is <quote>0</quote>.
+		</emphasis>
+	    </para>
+	    <example>
+		<title>Set <varname>cfgtrace_format</varname> parameter</title>
+		<programlisting format="linespecific">
+...
+modparam("debugger", "cfgtrace_format", 1)
+...
+</programlisting>
+	    </example>
+	</section>
+
 	<section id="dbg.p.breakpoint">
 	    <title><varname>breakpoint</varname> (int)</title>
 	    <para>




More information about the sr-dev mailing list