diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/gui-wizard-gtk/wizard.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/gui-wizard-gtk/wizard.c b/src/gui-wizard-gtk/wizard.c index 081fe3a7..f114f8ed 100644 --- a/src/gui-wizard-gtk/wizard.c +++ b/src/gui-wizard-gtk/wizard.c @@ -708,14 +708,21 @@ static void save_to_event_log(struct analyze_event_data *evd, const char *str) static void update_event_log_on_disk(const char *str) { + /* Load existing log */ struct dump_dir *dd = dd_opendir(g_dump_dir_name, 0); if (!dd) return; char *event_log = dd_load_text_ext(dd, FILENAME_EVENT_LOG, DD_FAIL_QUIETLY_ENOENT); + /* Append new log part to existing log */ + unsigned len = strlen(event_log); + if (len != 0 && event_log[len - 1] != '\n') + event_log = append_to_malloced_string(event_log, "\n"); event_log = append_to_malloced_string(event_log, str); + + /* Trim log according to size watermarks */ + len = strlen(event_log); char *new_log = event_log; - unsigned len = strlen(event_log); if (len > EVENT_LOG_HIGH_WATERMARK) { new_log += len - EVENT_LOG_LOW_WATERMARK; @@ -724,6 +731,7 @@ static void update_event_log_on_disk(const char *str) new_log++; } + /* Save */ dd_save_text(dd, FILENAME_EVENT_LOG, new_log); free(event_log); dd_close(dd); |