mirror of
https://github.com/tio/tio.git
synced 2026-05-01 14:57:59 +02:00
Allow strip escape sequence characters from log file
The log without escape key stripped is like: ^M[12:47:17] ACRN:\> ^M[12:47:17] ACRN:\>lasdfjklsdjf ^M ^M[12:47:18] Error: Invalid command. ^M[12:47:19] ACRN:\> ^M[12:47:26] ACRN:\> ^M[12:47:26] ACRN:\>sdafkljsdkaljfklsadjflksdjafjsda^H ^H^H... ^M ^M[12:47:31] Error: Invalid command. After strip escape key, the log is like: [12:49:18] ACRN:\> [12:49:19] ACRN:\> [12:49:19] ACRN:\>ls [12:49:19] Error: Invalid command. [12:49:19] ACRN:\> [12:49:19] ACRN:\>dfaslhj [12:49:24] Error: Invalid command. Beside escape key, it also handle backspace key as well.
This commit is contained in:
parent
1079991608
commit
c0c21b1814
5 changed files with 101 additions and 18 deletions
|
|
@ -48,6 +48,7 @@ struct option_t option =
|
|||
false, // No local echo
|
||||
false, // No timestamp
|
||||
"", // Log filename
|
||||
false, // Strip esc charaters from log file
|
||||
"" // Map string
|
||||
};
|
||||
|
||||
|
|
@ -67,6 +68,7 @@ void print_help(char *argv[])
|
|||
printf(" -t, --timestamp Prefix each new line with a timestamp\n");
|
||||
printf(" -l, --log <filename> Log to file\n");
|
||||
printf(" -m, --map <flags> Map special characters\n");
|
||||
printf(" -S, --strip-esc Strip esc characters from log file\n");
|
||||
printf(" -v, --version Display version\n");
|
||||
printf(" -h, --help Display help\n");
|
||||
printf("\n");
|
||||
|
|
@ -117,6 +119,7 @@ void parse_options(int argc, char *argv[])
|
|||
{"timestamp", no_argument, 0, 't'},
|
||||
{"log", required_argument, 0, 'l'},
|
||||
{"map", required_argument, 0, 'm'},
|
||||
{"strip-esc", no_argument, 0, 'S'},
|
||||
{"version", no_argument, 0, 'v'},
|
||||
{"help", no_argument, 0, 'h'},
|
||||
{0, 0, 0, 0 }
|
||||
|
|
@ -126,7 +129,7 @@ void parse_options(int argc, char *argv[])
|
|||
int option_index = 0;
|
||||
|
||||
/* Parse argument using getopt_long */
|
||||
c = getopt_long(argc, argv, "b:d:f:s:p:o:netl:m:vh", long_options, &option_index);
|
||||
c = getopt_long(argc, argv, "b:d:f:s:p:o:netl:m:Svh", long_options, &option_index);
|
||||
|
||||
/* Detect the end of the options */
|
||||
if (c == -1)
|
||||
|
|
@ -189,6 +192,10 @@ void parse_options(int argc, char *argv[])
|
|||
option.map = optarg;
|
||||
break;
|
||||
|
||||
case 'S':
|
||||
option.strip_esc = true;
|
||||
break;
|
||||
|
||||
case 'v':
|
||||
printf("tio v%s\n", VERSION);
|
||||
printf("Copyright (c) 2014-2018 Martin Lund\n");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue