From 482f8955d7ee21515a82d1844620385ad4503079 Mon Sep 17 00:00:00 2001 From: Michael Vetter Date: Mon, 28 Jun 2021 17:41:48 +0200 Subject: Fix log rotation See https://github.com/profanity-im/profanity/issues/1518 It has a good explanation of what happened: ``` Apparently, the _rotate_log_file function tried to extract user-provided name from currently used mainlogfile and restart logging to the same place after rotation, but currently this is interpreted as a full path instead. As I understand, the log rotation is no longer done with user-provided paths at all so this should be simply skipped altogether now as passing any non-NULL value is interpreted as user-provided. Replacing start with NULL appears to fix it for me. ``` In log_msg() we only rotate the log if not user_provided_log. https://github.com/profanity-im/profanity/pull/1455 changed the behaviour from user defined filename in the log dir to using full path. --- src/log.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'src') diff --git a/src/log.c b/src/log.c index 6dfc089a..66fe8abe 100644 --- a/src/log.c +++ b/src/log.c @@ -246,18 +246,12 @@ _rotate_log_file(void) break; } - char* lf = strdup(mainlogfile); - char* start = strrchr(lf, '/') + 1; - char* end = strstr(start, ".log"); - *end = '\0'; - log_close(); rename(log_file, log_file_new); - log_init(log_get_filter(), start); + log_init(log_get_filter(), log_file); - free(lf); free(log_file_new); free(log_file); log_info("Log has been rotated"); -- cgit 1.4.1-2-gfad0