From: Ben Pfaff Date: Thu, 24 Jul 2008 00:04:21 +0000 (-0700) Subject: vlog: Send multi-line log messages to syslog() one line at a time. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=42c89afbde5e0c59e1ddd92c9f81a5a969cb19a3;p=openvswitch vlog: Send multi-line log messages to syslog() one line at a time. syslogd swallows new-lines, which makes multi-line messages otherwise difficult to read. --- diff --git a/lib/vlog.c b/lib/vlog.c index 6494de93..9641bd95 100644 --- a/lib/vlog.c +++ b/lib/vlog.c @@ -350,8 +350,12 @@ vlog(enum vlog_module module, enum vlog_level level, const char *message, ...) [VLL_WARN] = LOG_WARNING, [VLL_DBG] = LOG_DEBUG, }; + char *line, *save_ptr; - syslog(syslog_levels[level], "%s", s + time_len); + for (line = strtok_r(s + time_len, "\n", &save_ptr); line != NULL; + line = strtok_r(NULL, "\n", &save_ptr)) { + syslog(syslog_levels[level], "%s", line); + } } errno = save_errno; }