]> git.ipfire.org Git - thirdparty/plymouth.git/commitdiff
logger: Add a separator between different boot logs
authorHans de Goede <hdegoede@redhat.com>
Tue, 17 Jul 2018 07:46:12 +0000 (09:46 +0200)
committerHans de Goede <hdegoede@redhat.com>
Mon, 12 Nov 2018 13:57:18 +0000 (14:57 +0100)
Since we concatenate boot logs one after the other in /var/log/boot.log
it is hard to tell where the logs from one boot end the next boot starts.

This commit makes plymouth write out a separator including a time + date
of the date, when the log file gets opened to add new boot messages to it.

Note ply_logger_open_file() is only called from ply_terminal_session_open_log()
which in turn is only used for /var/log/boot.log, so this only effects
/var/log/boot.log.

Closes #29

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
src/libply/ply-logger.c

index e9b90de2c5ad5c51187dfd6cea7cc7ff5083d1a9..03dd347fd51f899f8a052b2ae102c7d04476661c 100644 (file)
@@ -34,6 +34,7 @@
 #include <sys/file.h>
 #include <sys/stat.h>
 #include <sys/types.h>
+#include <time.h>
 #include <unistd.h>
 
 #include "ply-utils.h"
@@ -312,6 +313,9 @@ bool
 ply_logger_open_file (ply_logger_t *logger,
                       const char   *filename)
 {
+        char header[80];
+        struct tm* tm;
+        time_t t;
         int fd;
 
         assert (logger != NULL);
@@ -328,6 +332,15 @@ ply_logger_open_file (ply_logger_t *logger,
 
         logger->filename = strdup (filename);
 
+        time (&t);
+        tm = localtime (&t);
+        if (tm) {
+                /* This uses uname -v date format */
+                strftime (header, sizeof(header),
+                         "------------ %a %b %d %T %Z %Y ------------\n", tm);
+                ply_logger_write (logger, header, strlen(header), true);
+        }
+
         return true;
 }