Only rotate logs if user didn't specify a log file

This commit is contained in:
Michael Vetter
2020-12-11 11:33:34 +01:00
parent 57666bcb77
commit 0277ffe6ae
2 changed files with 8 additions and 2 deletions

View File

@@ -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();