summaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorpommicket <pommicket@gmail.com>2023-09-24 10:16:17 -0400
committerpommicket <pommicket@gmail.com>2023-09-24 10:16:17 -0400
commitcdf94949a4a12b0f99d855dcfb113905ac8a90f4 (patch)
tree4e31091de296fd901c9b317cb4ac259f604270ee /main.c
parentbf00aba72e89d4005c8a3b405bffa4c0a11d9c96 (diff)
don't truncate log on startup
Diffstat (limited to 'main.c')
-rw-r--r--main.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/main.c b/main.c
index 930d6da..8cdba9d 100644
--- a/main.c
+++ b/main.c
@@ -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;
}