Add --log-append option

Add --log-append option which makes tio append to any existing log file.

This also changes the default behaviour of tio from appending to
overwriting any existing log file. Now you have to use this new option
to make tio append.
This commit is contained in:
Martin Lund 2023-04-28 20:50:31 +02:00
parent 3bedd85e7c
commit 148a3c1da1
7 changed files with 28 additions and 2 deletions

View file

@ -69,8 +69,17 @@ int log_open(const char *filename)
log_filename = filename;
// Open log file in append write mode
fp = fopen(filename, "a+");
// Open log file
if (option.log_append)
{
// Appends to existing log file
fp = fopen(filename, "a+");
}
else
{
// Truncates existing log file
fp = fopen(filename, "w+");
}
if (fp == NULL)
{
tio_warning_printf("Could not open log file %s (%s)", filename, strerror(errno));