vlog: Send multi-line log messages to syslog() one line at a time.
authorBen Pfaff <blp@nicira.com>
Thu, 24 Jul 2008 00:04:21 +0000 (17:04 -0700)
committerBen Pfaff <blp@nicira.com>
Thu, 24 Jul 2008 00:04:21 +0000 (17:04 -0700)
syslogd swallows new-lines, which makes multi-line messages otherwise
difficult to read.

lib/vlog.c

index 6494de9322bdc33e213389083c8699808d3d0bc3..9641bd959f1e5daf7eb697801cbcfbe93cd2f977 100644 (file)
@@ -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;
     }