[Asterisk-code-review] pbx: disable extensions loading logs via config (asterisk[15])

Benoît Dereck-Tricot asteriskteam at digium.com
Thu Jan 11 23:58:52 CST 2018


Benoît Dereck-Tricot has uploaded this change for review. ( https://gerrit.asterisk.org/7938


Change subject: pbx: disable extensions loading logs via config
......................................................................

pbx: disable extensions loading logs via config

Loading extensions can generate a lot of "Added extension..." logs, especially
when you combine rich dialplans with frequent dialplan reloads.
A new parameter has been added in extensions.conf: disableloadinglogs, which
defaults to false.

ASTERISK-27084

Change-Id: I46af3f91ea6df9e302c9ee2afbbe08b5a2745a6e
---
M configs/samples/extensions.conf.sample
M include/asterisk/pbx.h
M main/pbx.c
M pbx/pbx_config.c
4 files changed, 25 insertions(+), 6 deletions(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/38/7938/1

diff --git a/configs/samples/extensions.conf.sample b/configs/samples/extensions.conf.sample
index db4c215..81cc3e3 100644
--- a/configs/samples/extensions.conf.sample
+++ b/configs/samples/extensions.conf.sample
@@ -36,7 +36,11 @@
 ;
 ;autofallthrough=no
 ;
+; Loading extensions can generate a lot of "Added extension..." logs, especially
+; when you combine rich dialplans with frequent dialplan reloads.
+; In such cases you may wish to set disableloadinglogs.
 ;
+;disableloadinglogs=yes
 ;
 ; If extenpatternmatchnew is set (true, yes, etc), then a new algorithm that uses
 ; a Trie to find the best matching pattern is used. In dialplans
diff --git a/include/asterisk/pbx.h b/include/asterisk/pbx.h
index c8c171a..cbd40de 100644
--- a/include/asterisk/pbx.h
+++ b/include/asterisk/pbx.h
@@ -1449,6 +1449,10 @@
   the old linear-search algorithm.  Returns previous value. */
 int pbx_set_extenpatternmatchnew(int newval);
 
+/*! Set the "disableloadinglogs" flag. If set, (re)loading the dialplan extensions will not
+  produce "Added extension..." logs. */
+void pbx_set_disableloadinglogs(int newval);
+
 /*! Set "overrideswitch" field.  If set and of nonzero length, all contexts
  * will be tried directly through the named switch prior to any other
  * matching within that context.
diff --git a/main/pbx.c b/main/pbx.c
index b850e8e..3ac66e7 100644
--- a/main/pbx.c
+++ b/main/pbx.c
@@ -761,6 +761,7 @@
 
 static int autofallthrough = 1;
 static int extenpatternmatchnew = 0;
+static int disableloadinglogs = 0;
 static char *overrideswitch = NULL;
 
 /*! \brief Subscription for device state change events */
@@ -4734,6 +4735,11 @@
 	return oldval;
 }
 
+void pbx_set_disableloadinglogs(int newval)
+{
+	disableloadinglogs = newval;
+}
+
 void pbx_set_overrideswitch(const char *newval)
 {
 	if (overrideswitch) {
@@ -7516,12 +7522,14 @@
 		}
 	}
 
-	if (tmp->matchcid == AST_EXT_MATCHCID_ON) {
-		ast_verb(3, "Added extension '%s' priority %d (CID match '%s') to %s\n",
-				 tmp->name, tmp->priority, tmp->cidmatch_display, con->name);
-	} else {
-		ast_verb(3, "Added extension '%s' priority %d to %s\n",
-				 tmp->name, tmp->priority, con->name);
+	if (!disableloadinglogs) {
+		if (tmp->matchcid == AST_EXT_MATCHCID_ON) {
+			ast_verb(3, "Added extension '%s' priority %d (CID match '%s') to %s\n",
+					 tmp->name, tmp->priority, tmp->cidmatch_display, con->name);
+		} else {
+			ast_verb(3, "Added extension '%s' priority %d to %s\n",
+					 tmp->name, tmp->priority, con->name);
+		}
 	}
 
 	return 0;
diff --git a/pbx/pbx_config.c b/pbx/pbx_config.c
index 9577d2d..fa59e5c 100644
--- a/pbx/pbx_config.c
+++ b/pbx/pbx_config.c
@@ -1688,6 +1688,7 @@
 	const char *cxt;
 	const char *aft;
 	const char *newpm, *ovsw;
+	const char *extlogsdisabled;
 	struct ast_flags config_flags = { 0 };
 	char lastextension[256];
 	cfg = ast_config_load(config_file, config_flags);
@@ -1701,6 +1702,8 @@
 		autofallthrough_config = ast_true(aft);
 	if ((newpm = ast_variable_retrieve(cfg, "general", "extenpatternmatchnew")))
 		extenpatternmatchnew_config = ast_true(newpm);
+	if ((extlogsdisabled = ast_variable_retrieve(cfg, "general", "disableloadinglogs")))
+		pbx_set_disableloadinglogs(ast_true(extlogsdisabled));
 	clearglobalvars_config = ast_true(ast_variable_retrieve(cfg, "general", "clearglobalvars"));
 	if ((ovsw = ast_variable_retrieve(cfg, "general", "overrideswitch"))) {
 		if (overrideswitch_config) {

-- 
To view, visit https://gerrit.asterisk.org/7938
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 15
Gerrit-MessageType: newchange
Gerrit-Change-Id: I46af3f91ea6df9e302c9ee2afbbe08b5a2745a6e
Gerrit-Change-Number: 7938
Gerrit-PatchSet: 1
Gerrit-Owner: Benoît Dereck-Tricot <benoit.dereck-tricot at eyepea.eu>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20180111/89ddcbd6/attachment-0001.html>


More information about the asterisk-code-review mailing list