Change in osmo-sip-connector[master]: logging from sofia: add missing newline

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

neels gerrit-no-reply at lists.osmocom.org
Mon Nov 25 23:18:53 UTC 2019


neels has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-sip-connector/+/16220 )


Change subject: logging from sofia: add missing newline
......................................................................

logging from sofia: add missing newline

Sometimes, lgging from sofia lacks the final newline character, messing up log
output. First snprintf() to a buffer, add '\n' if necessary and then log.

Change-Id: Ia26c0b57a0166cf7de87c49471ce6f528a366dd5
---
M src/sip.c
1 file changed, 10 insertions(+), 1 deletion(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-sip-connector refs/changes/20/16220/1

diff --git a/src/sip.c b/src/sip.c
index 2b28b4e..5eaa94b 100644
--- a/src/sip.c
+++ b/src/sip.c
@@ -666,7 +666,16 @@
 	 * the log handler call-back function, so we have no clue what log level the
 	 * currently logged message was sent for :(  As a result, we can only use one
 	 * hard-coded LOGL_NOTICE here */
-	osmo_vlogp(DSIP, LOGL_NOTICE, "", 0, 0, fmt, ap);
+	if (!log_check_level(DSIP, LOGL_NOTICE))
+		return;
+	/* The sofia-sip log line *sometimes* lacks a terminating '\n'. Add it. */
+	char log_line[256];
+	if (vsnprintf(log_line, sizeof(log_line), fmt, ap) > 0) {
+		char *end = log_line + OSMO_MIN(strlen(log_line), sizeof(log_line) - 2);
+		osmo_strlcpy(end, "\n", 2);
+		LOGP(DSIP, LOGL_NOTICE, "%s", log_line);
+	} else
+		LOGP(DSIP, LOGL_NOTICE, "unknown logging from sip\n");
 }
 
 void sip_agent_init(struct sip_agent *agent, struct app_config *app)

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-sip-connector/+/16220
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-sip-connector
Gerrit-Branch: master
Gerrit-Change-Id: Ia26c0b57a0166cf7de87c49471ce6f528a366dd5
Gerrit-Change-Number: 16220
Gerrit-PatchSet: 1
Gerrit-Owner: neels <nhofmeyr at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20191125/4a5e4b04/attachment.htm>


More information about the gerrit-log mailing list