mirror of
https://github.com/tio/tio.git
synced 2026-05-01 14:57:59 +02:00
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:
parent
3bedd85e7c
commit
148a3c1da1
7 changed files with 28 additions and 2 deletions
|
|
@ -198,6 +198,10 @@ static int data_handler(void *user, const char *section, const char *name,
|
|||
asprintf(&c.log_filename, "%s", value);
|
||||
option.log_filename = c.log_filename;
|
||||
}
|
||||
else if (!strcmp(name, "log-append"))
|
||||
{
|
||||
option.log_append = read_boolean(value, name);
|
||||
}
|
||||
else if (!strcmp(name, "log-strip"))
|
||||
{
|
||||
option.log_strip = read_boolean(value, name);
|
||||
|
|
|
|||
13
src/log.c
13
src/log.c
|
|
@ -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));
|
||||
|
|
|
|||
|
|
@ -74,6 +74,7 @@ struct option_t option =
|
|||
.ri_pulse_duration = 100,
|
||||
.no_autoconnect = false,
|
||||
.log = false,
|
||||
.log_append = false,
|
||||
.log_filename = NULL,
|
||||
.log_strip = false,
|
||||
.local_echo = false,
|
||||
|
|
@ -119,6 +120,7 @@ void print_help(char *argv[])
|
|||
printf(" -L, --list-devices List available serial devices by ID\n");
|
||||
printf(" -l, --log Enable log to file\n");
|
||||
printf(" --log-file <filename> Set log filename\n");
|
||||
printf(" --log-append Append to log file\n");
|
||||
printf(" --log-strip Strip control characters and escape sequences\n");
|
||||
printf(" -m, --map <flags> Map characters\n");
|
||||
printf(" -c, --color 0..255|bold|none|list Colorize tio text (default: bold)\n");
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@ struct option_t
|
|||
unsigned int ri_pulse_duration;
|
||||
bool no_autoconnect;
|
||||
bool log;
|
||||
bool log_append;
|
||||
bool log_strip;
|
||||
bool local_echo;
|
||||
enum timestamp_t timestamp;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue