mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
Iterate logfiles until 100 are reached
Fix https://github.com/profanity-im/profanity/issues/519
This commit is contained in:
parent
1f3d61e9f7
commit
bb4dd47a01
15
src/log.c
15
src/log.c
@ -227,14 +227,17 @@ log_level_from_string(char *log_level)
|
|||||||
static void
|
static void
|
||||||
_rotate_log_file(void)
|
_rotate_log_file(void)
|
||||||
{
|
{
|
||||||
char *log_file = files_get_log_file();
|
gchar *log_file = files_get_log_file();
|
||||||
size_t len = strlen(log_file);
|
size_t len = strlen(log_file);
|
||||||
char *log_file_new = malloc(len + 3);
|
gchar *log_file_new = malloc(len + 4);
|
||||||
|
int i = 1;
|
||||||
|
|
||||||
memcpy(log_file_new, log_file, len);
|
// find an empty name. from .log -> log.01 -> log.99
|
||||||
log_file_new[len] = '.';
|
for(; i<100; i++) {
|
||||||
log_file_new[len+1] = '1';
|
g_sprintf(log_file_new, "%s.%02d", log_file, i);
|
||||||
log_file_new[len+2] = 0;
|
if (!g_file_test(log_file_new, G_FILE_TEST_EXISTS))
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
log_close();
|
log_close();
|
||||||
rename(log_file, log_file_new);
|
rename(log_file, log_file_new);
|
||||||
|
Loading…
Reference in New Issue
Block a user