From c4ffec57b43ba19e1d59bc6dc98963c4053014da Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Sun, 16 Dec 2018 15:55:45 +1030 Subject: [PATCH] log: play back prior log entries when opening log. Signed-off-by: Rusty Russell --- lightningd/log.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lightningd/log.c b/lightningd/log.c index 1aa020392..9b672e48e 100644 --- a/lightningd/log.c +++ b/lightningd/log.c @@ -502,6 +502,7 @@ static void setup_log_rotation(struct lightningd *ld) char *arg_log_to_file(const char *arg, struct lightningd *ld) { + const struct log_entry *i; FILE *logf; if (ld->logfile) { @@ -515,6 +516,12 @@ char *arg_log_to_file(const char *arg, struct lightningd *ld) if (!logf) return tal_fmt(NULL, "Failed to open: %s", strerror(errno)); set_log_outfn(ld->log->lr, log_to_file, logf); + + /* Catch up */ + list_for_each(&ld->log->lr->log, i, list) + maybe_print(ld->log, i, 0); + + log_debug(ld->log, "Opened log file %s", arg); return NULL; }