mirror of
https://github.com/tio/tio.git
synced 2026-05-01 14:57:59 +02:00
Refine timestamps with milliseconds and ISO-8601 format (#129).
* Show milliseconds too in the timestamp (#114) and log file (#124) * Change timestamp format to ISO-8601. Co-authored-by: Attila Veghelyi <aveghelyi@dension.com> Co-authored-by: Sylvain LAFRASSE <sly74fr@users.noreply.github.com>
This commit is contained in:
parent
101e32749b
commit
65153c0d03
2 changed files with 31 additions and 20 deletions
30
src/tty.c
30
src/tty.c
|
|
@ -619,7 +619,7 @@ int tty_connect(void)
|
|||
static char previous_char = 0;
|
||||
static bool first = true;
|
||||
int status;
|
||||
time_t next_timestamp = 0;
|
||||
bool next_timestamp = false;
|
||||
char* now = NULL;
|
||||
|
||||
/* Open tty device */
|
||||
|
|
@ -658,7 +658,7 @@ int tty_connect(void)
|
|||
tainted = false;
|
||||
|
||||
if (option.timestamp)
|
||||
next_timestamp = time(NULL);
|
||||
next_timestamp = true;
|
||||
|
||||
/* Save current port settings */
|
||||
if (tcgetattr(fd, &tio_old) < 0)
|
||||
|
|
@ -715,19 +715,21 @@ int tty_connect(void)
|
|||
if (next_timestamp && input_char != '\n' && input_char != '\r')
|
||||
{
|
||||
now = current_time();
|
||||
fprintf(stdout, ANSI_COLOR_GRAY "[%s] " ANSI_COLOR_RESET, now);
|
||||
if (option.log)
|
||||
{
|
||||
log_write('[');
|
||||
while (*now != '\0')
|
||||
if (now) {
|
||||
fprintf(stdout, ANSI_COLOR_GRAY "[%s] " ANSI_COLOR_RESET, now);
|
||||
if (option.log)
|
||||
{
|
||||
log_write(*now);
|
||||
++now;
|
||||
log_write('[');
|
||||
while (*now != '\0')
|
||||
{
|
||||
log_write(*now);
|
||||
++now;
|
||||
}
|
||||
log_write(']');
|
||||
log_write(' ');
|
||||
}
|
||||
log_write(']');
|
||||
log_write(' ');
|
||||
next_timestamp = false;
|
||||
}
|
||||
next_timestamp = 0;
|
||||
}
|
||||
|
||||
/* Map input character */
|
||||
|
|
@ -736,7 +738,7 @@ int tty_connect(void)
|
|||
print('\r');
|
||||
print('\n');
|
||||
if (option.timestamp)
|
||||
next_timestamp = time(NULL);
|
||||
next_timestamp = true;
|
||||
} else
|
||||
{
|
||||
/* Print received tty character to stdout */
|
||||
|
|
@ -751,7 +753,7 @@ int tty_connect(void)
|
|||
tainted = true;
|
||||
|
||||
if (input_char == '\n' && option.timestamp)
|
||||
next_timestamp = time(NULL);
|
||||
next_timestamp = true;
|
||||
} else
|
||||
{
|
||||
/* Error reading - device is likely unplugged */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue