Change in libosmo-abis[master]: osmo_ortp: Log domain and fix strings without endl char

Pau Espin Pedrol gerrit-no-reply at lists.osmocom.org
Mon Nov 12 16:27:00 UTC 2018


Pau Espin Pedrol has uploaded this change for review. ( https://gerrit.osmocom.org/11744


Change subject: osmo_ortp: Log domain and fix strings without endl char
......................................................................

osmo_ortp: Log domain and fix strings without endl char

Change-Id: Ib6df0df04cd6ba342753c84398274d04917ace40
---
M src/trau/osmo_ortp.c
1 file changed, 28 insertions(+), 1 deletion(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmo-abis refs/changes/44/11744/1

diff --git a/src/trau/osmo_ortp.c b/src/trau/osmo_ortp.c
index d8f4abf..0eb1661 100644
--- a/src/trau/osmo_ortp.c
+++ b/src/trau/osmo_ortp.c
@@ -102,8 +102,35 @@
 #endif
 	OrtpLogLevel lev, const char *fmt, va_list args)
 {
+	/* Some strings coming from ortp are not endline terminated and mangle
+	 * the output. Make sure all strings are endl terminated before
+	 * printing.
+	 */
+	int needs_endl;
+	const char *domain_str;
+	char *str;
+	size_t fmt_len = strlen(fmt);
+#if HAVE_ORTP_LOG_DOMAIN
+	/* domain can be NULL, found experimentally */
+	domain_str = domain ? : "";
+#else
+	domain_str = "";
+#endif
+	size_t  domain_len = strlen(domain_str);
+
+	if (fmt_len == 0)
+		return;
+
+	needs_endl = fmt[fmt_len - 1] != '\n' ? 1 : 0;
+
+	str = osmo_ortp_malloc(domain_len + 2 /*": "*/ + fmt_len + needs_endl + 1);
+	sprintf(str, "%s%s%s%s", domain_str, domain_len ? ": " : "", fmt, needs_endl ? "\n" : "");
+
 	osmo_vlogp(DLMIB, ortp_to_osmo_lvl(lev), __FILE__, 0,
-		   0, fmt, args);
+		   0, str, args);
+
+	osmo_ortp_free(str);
+
 }
 
 /* ORTP signal callbacks */

-- 
To view, visit https://gerrit.osmocom.org/11744
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: libosmo-abis
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib6df0df04cd6ba342753c84398274d04917ace40
Gerrit-Change-Number: 11744
Gerrit-PatchSet: 1
Gerrit-Owner: Pau Espin Pedrol <pespin at sysmocom.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20181112/3b9192bf/attachment.html>


More information about the gerrit-log mailing list