summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeels Hofmeyr <neels@hofmeyr.de>2019-11-18 15:41:28 +0100
committerNeels Hofmeyr <neels@hofmeyr.de>2019-11-25 05:08:27 +0100
commit1cbd9e6ac0a42187f4efdec23f581fd4eb6cb065 (patch)
treed80b03684604e2137f5d124c7e84f728a7d61369
parent71fa54959c6880e4ece4847bbd6177c1379a2b93 (diff)
logging from sofia: add missing newlineneels/codecs
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
-rw-r--r--src/sip.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/sip.c b/src/sip.c
index 072b8ab..e7faaf2 100644
--- a/src/sip.c
+++ b/src/sip.c
@@ -625,7 +625,16 @@ static void sip_logger(void *stream, char const *fmt, va_list ap)
* 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)