<p>N A has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/19575">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">res_pjsip_logger: Preserve logging state on reloads.<br><br>Currently, reloading res_pjsip will cause logging<br>to be disabled. This is because logging can also<br>be controlled via the debug option in pjsip.conf<br>and this defaults to "no".<br><br>To improve this, logging is no longer disabled on<br>reloads if logging had not been previously<br>enabled using the debug option from the config.<br>This ensures that logging enabled from the CLI<br>will persist through a reload.<br><br>ASTERISK-29912 #close<br><br>Change-Id: I0be7d90e7007f5a6bc4a1cb75019fbaeb18428da<br>---<br>A doc/CHANGES-staging/res_pjsip_logger_debug.txt<br>M res/res_pjsip_logger.c<br>2 files changed, 41 insertions(+), 1 deletion(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/75/19575/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/doc/CHANGES-staging/res_pjsip_logger_debug.txt b/doc/CHANGES-staging/res_pjsip_logger_debug.txt</span><br><span>new file mode 100644</span><br><span>index 0000000..1365aab</span><br><span>--- /dev/null</span><br><span>+++ b/doc/CHANGES-staging/res_pjsip_logger_debug.txt</span><br><span>@@ -0,0 +1,5 @@</span><br><span style="color: hsl(120, 100%, 40%);">+Subject: res_pjsip_logger</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+Issuing "pjsip reload" will no longer</span><br><span style="color: hsl(120, 100%, 40%);">+disabling logging if it was previously</span><br><span style="color: hsl(120, 100%, 40%);">+enabled from the CLI.</span><br><span>diff --git a/res/res_pjsip_logger.c b/res/res_pjsip_logger.c</span><br><span>index 456bb22..7fbec0c 100644</span><br><span>--- a/res/res_pjsip_logger.c</span><br><span>+++ b/res/res_pjsip_logger.c</span><br><span>@@ -129,6 +129,9 @@</span><br><span> /*! \brief The default logger session */</span><br><span> static struct pjsip_logger_session *default_logger;</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+/*! \brief Whether or not the logger was enabled via the debug option in pjsip.conf (as opposed to via CLI) */</span><br><span style="color: hsl(120, 100%, 40%);">+static int logger_enabled_via_config = 0;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> /*! \brief Destructor for logger session */</span><br><span> static void pjsip_logger_session_destroy(void *obj)</span><br><span> {</span><br><span>@@ -665,10 +668,20 @@</span><br><span> RAII_VAR(char *, debug, ast_sip_get_debug(), ast_free);</span><br><span> </span><br><span> if (ast_false(debug)) {</span><br><span style="color: hsl(0, 100%, 40%);">- pjsip_disable_logger(-1);</span><br><span style="color: hsl(120, 100%, 40%);">+ /* If the logger was enabled via the CLI instead of</span><br><span style="color: hsl(120, 100%, 40%);">+ * through the config file, then we shouldn't</span><br><span style="color: hsl(120, 100%, 40%);">+ * disable it on a reload.</span><br><span style="color: hsl(120, 100%, 40%);">+ * Only disable logging if the logger was previously</span><br><span style="color: hsl(120, 100%, 40%);">+ * enabled via the config file. */</span><br><span style="color: hsl(120, 100%, 40%);">+ if (logger_enabled_via_config) {</span><br><span style="color: hsl(120, 100%, 40%);">+ pjsip_disable_logger(-1);</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ logger_enabled_via_config = 0;</span><br><span> return;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+ logger_enabled_via_config = 1;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> if (ast_true(debug)) {</span><br><span> pjsip_enable_logger_all(-1);</span><br><span> return;</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/19575">change 19575</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/c/asterisk/+/19575"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: I0be7d90e7007f5a6bc4a1cb75019fbaeb18428da </div>
<div style="display:none"> Gerrit-Change-Number: 19575 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: N A <asterisk@phreaknet.org> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>