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
|
|
@ -22,6 +22,7 @@ no-autoconnect = disable
|
||||||
hexadecimal = disable
|
hexadecimal = disable
|
||||||
timestamp = disable
|
timestamp = disable
|
||||||
log = disable
|
log = disable
|
||||||
|
log-append = disable
|
||||||
log-strip = disable
|
log-strip = disable
|
||||||
local-echo = disable
|
local-echo = disable
|
||||||
color = bold
|
color = bold
|
||||||
|
|
|
||||||
|
|
@ -141,6 +141,11 @@ The filename can be manually set using the \-\-log-file option.
|
||||||
|
|
||||||
Set log filename.
|
Set log filename.
|
||||||
|
|
||||||
|
.TP
|
||||||
|
.BR " \-\-log-append
|
||||||
|
|
||||||
|
Append to log file.
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
.BR " \-\-log-strip
|
.BR " \-\-log-strip
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -108,6 +108,10 @@ OPTIONS
|
||||||
|
|
||||||
Set log filename.
|
Set log filename.
|
||||||
|
|
||||||
|
--log-append
|
||||||
|
|
||||||
|
Append to log file.
|
||||||
|
|
||||||
--log-strip
|
--log-strip
|
||||||
|
|
||||||
Strip control characters and escape sequences from log.
|
Strip control characters and escape sequences from log.
|
||||||
|
|
|
||||||
|
|
@ -198,6 +198,10 @@ static int data_handler(void *user, const char *section, const char *name,
|
||||||
asprintf(&c.log_filename, "%s", value);
|
asprintf(&c.log_filename, "%s", value);
|
||||||
option.log_filename = c.log_filename;
|
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"))
|
else if (!strcmp(name, "log-strip"))
|
||||||
{
|
{
|
||||||
option.log_strip = read_boolean(value, name);
|
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;
|
log_filename = filename;
|
||||||
|
|
||||||
// Open log file in append write mode
|
// Open log file
|
||||||
fp = fopen(filename, "a+");
|
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)
|
if (fp == NULL)
|
||||||
{
|
{
|
||||||
tio_warning_printf("Could not open log file %s (%s)", filename, strerror(errno));
|
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,
|
.ri_pulse_duration = 100,
|
||||||
.no_autoconnect = false,
|
.no_autoconnect = false,
|
||||||
.log = false,
|
.log = false,
|
||||||
|
.log_append = false,
|
||||||
.log_filename = NULL,
|
.log_filename = NULL,
|
||||||
.log_strip = false,
|
.log_strip = false,
|
||||||
.local_echo = 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, --list-devices List available serial devices by ID\n");
|
||||||
printf(" -l, --log Enable log to file\n");
|
printf(" -l, --log Enable log to file\n");
|
||||||
printf(" --log-file <filename> Set log filename\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(" --log-strip Strip control characters and escape sequences\n");
|
||||||
printf(" -m, --map <flags> Map characters\n");
|
printf(" -m, --map <flags> Map characters\n");
|
||||||
printf(" -c, --color 0..255|bold|none|list Colorize tio text (default: bold)\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;
|
unsigned int ri_pulse_duration;
|
||||||
bool no_autoconnect;
|
bool no_autoconnect;
|
||||||
bool log;
|
bool log;
|
||||||
|
bool log_append;
|
||||||
bool log_strip;
|
bool log_strip;
|
||||||
bool local_echo;
|
bool local_echo;
|
||||||
enum timestamp_t timestamp;
|
enum timestamp_t timestamp;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue