<p>fixeria has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.osmocom.org/c/libosmocore/+/23630">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">vty/logging: logp: properly handle library specific sub-systems<br><br>The library specific sub-systems are kind of special, because their<br>position in the 'osmo_log_info' may vary depending on the number of<br>application specific sub-systems.  This is why their associated<br>constant values (like DLGLOBAL) are negative, and this is what<br>the LOGP() macro expects as the first argument.<br><br>Before this change, invoking 'logp' command with any library<br>specific logging sub-system would result in getting messages<br>printed with the fall-back DLGLOBAL sub-systems.<br><br>Change-Id: If86563e169fe1243adfa7b09c9d65d9f88c8a99e<br>---<br>M src/vty/logging_vty.c<br>M tests/logging/logging_vty_test.vty<br>2 files changed, 20 insertions(+), 0 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/30/23630/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/src/vty/logging_vty.c b/src/vty/logging_vty.c</span><br><span>index 5f31b39..3b131c2 100644</span><br><span>--- a/src/vty/logging_vty.c</span><br><span>+++ b/src/vty/logging_vty.c</span><br><span>@@ -1110,6 +1110,23 @@</span><br><span>      int category = log_parse_category(argv[0]);</span><br><span>  int level = log_parse_level(argv[1]);</span><br><span>        char *str = argv_concat(argv, argc, 2);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+     if (level < 0) {</span><br><span style="color: hsl(120, 100%, 40%);">+           vty_out(vty, "%% Invalid level '%s'%s", argv[1], VTY_NEWLINE);</span><br><span style="color: hsl(120, 100%, 40%);">+              return CMD_WARNING;</span><br><span style="color: hsl(120, 100%, 40%);">+   }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+   if (category < 0) {</span><br><span style="color: hsl(120, 100%, 40%);">+                vty_out(vty, "%% Invalid category '%s'%s", argv[0], VTY_NEWLINE);</span><br><span style="color: hsl(120, 100%, 40%);">+           return CMD_WARNING;</span><br><span style="color: hsl(120, 100%, 40%);">+   }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+   /* Properly handle library specific sub-systems */</span><br><span style="color: hsl(120, 100%, 40%);">+    if ((unsigned int) category >= osmo_log_info->num_cat_user) {</span><br><span style="color: hsl(120, 100%, 40%);">+           category -= osmo_log_info->num_cat_user - 1;</span><br><span style="color: hsl(120, 100%, 40%);">+               category *= -1;</span><br><span style="color: hsl(120, 100%, 40%);">+       }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span>  LOGP(category, level, "%s\n", str);</span><br><span>        return CMD_SUCCESS;</span><br><span> }</span><br><span>diff --git a/tests/logging/logging_vty_test.vty b/tests/logging/logging_vty_test.vty</span><br><span>index 91c2a48..68d132a 100644</span><br><span>--- a/tests/logging/logging_vty_test.vty</span><br><span>+++ b/tests/logging/logging_vty_test.vty</span><br><span>@@ -526,3 +526,6 @@</span><br><span> logging_vty_test# logp lglobal debug This log message is not echoed</span><br><span> logging_vty_test# logp lglobal notice This log message is echoed</span><br><span> DLGLOBAL NOTICE This log message is echoed</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+logging_vty_test# logp dlctrl notice This is a CTRL specific message</span><br><span style="color: hsl(120, 100%, 40%);">+DLCTRL NOTICE This is a CTRL specific message</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/c/libosmocore/+/23630">change 23630</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.osmocom.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.osmocom.org/c/libosmocore/+/23630"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: libosmocore </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: If86563e169fe1243adfa7b09c9d65d9f88c8a99e </div>
<div style="display:none"> Gerrit-Change-Number: 23630 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: fixeria <vyanitskiy@sysmocom.de> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>