about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorMichael Vetter <jubalh@iodoru.org>2020-12-11 11:33:34 +0100
committerMichael Vetter <jubalh@iodoru.org>2020-12-11 11:33:34 +0100
commit0277ffe6ae69d0e3b417d7b89abbf801f27478a3 (patch)
tree91b7c0bdba2a717871170e8759863f60c05b08a7
parent57666bcb77f0c6aa26cd8647572a0f8349e335c5 (diff)
downloadprofani-tty-0277ffe6ae69d0e3b417d7b89abbf801f27478a3.tar.gz
Only rotate logs if user didn't specify a log file
-rw-r--r--src/command/cmd_defs.c2
-rw-r--r--src/log.c8
2 files changed, 8 insertions, 2 deletions
diff --git a/src/command/cmd_defs.c b/src/command/cmd_defs.c
index 03e1d4be..e876b647 100644
--- a/src/command/cmd_defs.c
+++ b/src/command/cmd_defs.c
@@ -1857,7 +1857,7 @@ static struct cmd_t command_defs[] = {
               "Manage profanity log settings.")
       CMD_ARGS(
               { "where", "Show the current log file location." },
-              { "rotate on|off", "Rotate log, default on." },
+              { "rotate on|off", "Rotate log, default on. Does not take effect if you specified a filename yourself when starting Profanity." },
               { "maxsize <bytes>", "With rotate enabled, specifies the max log size, defaults to 1048580 (1MB)." },
               { "shared on|off", "Share logs between all instances, default: on. When off, the process id will be included in the log filename. Does not take effect if you specified a filename yourself when starting Profanity." })
       CMD_NOEXAMPLES
diff --git a/src/log.c b/src/log.c
index 93488b28..10ca6389 100644
--- a/src/log.c
+++ b/src/log.c
@@ -56,6 +56,7 @@
 
 static FILE* logp;
 static gchar* mainlogfile = NULL;
+static gboolean user_provided_log = FALSE;
 
 static GTimeZone* tz;
 static GDateTime* dt;
@@ -150,6 +151,11 @@ log_init(log_level_t filter, char* log_file)
 {
     level_filter = filter;
     tz = g_time_zone_new_local();
+
+    if (log_file) {
+        user_provided_log = TRUE;
+    }
+
     gchar* lf = files_get_log_file(log_file);
 
     logp = fopen(lf, "a");
@@ -198,7 +204,7 @@ log_msg(log_level_t level, const char* const area, const char* const msg)
         fflush(logp);
         g_free(date_fmt);
 
-        if (prefs_get_boolean(PREF_LOG_ROTATE)) {
+        if (prefs_get_boolean(PREF_LOG_ROTATE) && !user_provided_log) {
             long result = ftell(logp);
             if (result != -1 && result >= prefs_get_max_log_size()) {
                 _rotate_log_file();