logging: Make sure ringbuffer messages are terminated with a newline
authorAmitay Isaacs <amitay@gmail.com>
Wed, 8 May 2013 13:29:55 +0000 (23:29 +1000)
committerAmitay Isaacs <amitay@gmail.com>
Thu, 23 May 2013 23:15:08 +0000 (09:15 +1000)
Signed-off-by: Amitay Isaacs <amitay@gmail.com>
common/ctdb_logging.c

index 339198b013f1894d86f83399a2849b393bafb633..408fda8658d7cc3994d3edd5811f6bf75c4fba91 100644 (file)
@@ -67,6 +67,12 @@ static void log_ringbuffer_v(const char *format, va_list ap)
        if (ret == -1) {
                return;
        }
+       /* Log messages longer than MAX_LOG_SIZE are truncated to MAX_LOG_SIZE-1
+        * bytes.  In that case, add a newline.
+        */
+       if (ret >= MAX_LOG_SIZE) {
+               log_entries[next_entry].message[MAX_LOG_SIZE-2] = '\n';
+       }
 
        log_entries[next_entry].level = this_log_level;
        log_entries[next_entry].t = timeval_current();