1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-11-03 19:37:16 -05:00

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

@ -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

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