[Asterisk-code-review] res_pjsip_logger: Preserve logging state on reloads. (asterisk[master])

N A asteriskteam at digium.com
Tue Nov 22 17:42:33 CST 2022


N A has uploaded this change for review. ( https://gerrit.asterisk.org/c/asterisk/+/19575 )


Change subject: res_pjsip_logger: Preserve logging state on reloads.
......................................................................

res_pjsip_logger: Preserve logging state on reloads.

Currently, reloading res_pjsip will cause logging
to be disabled. This is because logging can also
be controlled via the debug option in pjsip.conf
and this defaults to "no".

To improve this, logging is no longer disabled on
reloads if logging had not been previously
enabled using the debug option from the config.
This ensures that logging enabled from the CLI
will persist through a reload.

ASTERISK-29912 #close

Change-Id: I0be7d90e7007f5a6bc4a1cb75019fbaeb18428da
---
A doc/CHANGES-staging/res_pjsip_logger_debug.txt
M res/res_pjsip_logger.c
2 files changed, 41 insertions(+), 1 deletion(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/75/19575/1

diff --git a/doc/CHANGES-staging/res_pjsip_logger_debug.txt b/doc/CHANGES-staging/res_pjsip_logger_debug.txt
new file mode 100644
index 0000000..1365aab
--- /dev/null
+++ b/doc/CHANGES-staging/res_pjsip_logger_debug.txt
@@ -0,0 +1,5 @@
+Subject: res_pjsip_logger
+
+Issuing "pjsip reload" will no longer
+disabling logging if it was previously
+enabled from the CLI.
diff --git a/res/res_pjsip_logger.c b/res/res_pjsip_logger.c
index 456bb22..7fbec0c 100644
--- a/res/res_pjsip_logger.c
+++ b/res/res_pjsip_logger.c
@@ -129,6 +129,9 @@
 /*! \brief The default logger session */
 static struct pjsip_logger_session *default_logger;
 
+/*! \brief Whether or not the logger was enabled via the debug option in pjsip.conf (as opposed to via CLI) */
+static int logger_enabled_via_config = 0;
+
 /*! \brief Destructor for logger session */
 static void pjsip_logger_session_destroy(void *obj)
 {
@@ -665,10 +668,20 @@
 	RAII_VAR(char *, debug, ast_sip_get_debug(), ast_free);
 
 	if (ast_false(debug)) {
-		pjsip_disable_logger(-1);
+		/* If the logger was enabled via the CLI instead of
+		 * through the config file, then we shouldn't
+		 * disable it on a reload.
+		 * Only disable logging if the logger was previously
+		 * enabled via the config file. */
+		if (logger_enabled_via_config) {
+			pjsip_disable_logger(-1);
+		}
+		logger_enabled_via_config = 0;
 		return;
 	}
 
+	logger_enabled_via_config = 1;
+
 	if (ast_true(debug)) {
 		pjsip_enable_logger_all(-1);
 		return;

-- 
To view, visit https://gerrit.asterisk.org/c/asterisk/+/19575
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Change-Id: I0be7d90e7007f5a6bc4a1cb75019fbaeb18428da
Gerrit-Change-Number: 19575
Gerrit-PatchSet: 1
Gerrit-Owner: N A <asterisk at phreaknet.org>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20221122/d5b8eed5/attachment.html>


More information about the asterisk-code-review mailing list