diff options
author | pommicket <pommicket@gmail.com> | 2023-09-24 10:16:17 -0400 |
---|---|---|
committer | pommicket <pommicket@gmail.com> | 2023-09-24 10:16:17 -0400 |
commit | cdf94949a4a12b0f99d855dcfb113905ac8a90f4 (patch) | |
tree | 4e31091de296fd901c9b317cb4ac259f604270ee /main.c | |
parent | bf00aba72e89d4005c8a3b405bffa4c0a11d9c96 (diff) |
don't truncate log on startup
Diffstat (limited to 'main.c')
-rw-r--r-- | main.c | 9 |
1 files changed, 8 insertions, 1 deletions
@@ -397,9 +397,16 @@ int main(int argc, char **argv) { // open log file FILE *log = NULL; char log_filename[TED_PATH_MAX]; + char log1_filename[TED_PATH_MAX]; strbuf_printf(log_filename, "%s/log.txt", ted->local_data_dir); - log = fopen(log_filename, "w"); + strbuf_printf(log1_filename, "%s/log.1.txt", ted->local_data_dir); + if (fs_file_size(log_filename) > 500000) { + remove(log1_filename); + rename(log_filename, log1_filename); + } + log = fopen(log_filename, "a"); setbuf(log, NULL); + fprintf(log, "---- (starting ted, pid = %d) ----\n", process_get_id()); ted->log = log; } |