From: Hans de Goede Date: Tue, 17 Jul 2018 07:46:12 +0000 (+0200) Subject: logger: Add a separator between different boot logs X-Git-Tag: 0.9.5~87^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4de54f598b66cd8d8fc55328f99f3b568cc9d4eb;p=thirdparty%2Fplymouth.git logger: Add a separator between different boot logs 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 --- diff --git a/src/libply/ply-logger.c b/src/libply/ply-logger.c index e9b90de2..03dd347f 100644 --- a/src/libply/ply-logger.c +++ b/src/libply/ply-logger.c @@ -34,6 +34,7 @@ #include #include #include +#include #include #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; }