mirror of
https://github.com/tio/tio.git
synced 2026-05-01 14:57:59 +02:00
Resolved tio/tio#84: Added timestamps in log file if enabled.
This commit is contained in:
parent
39a8f63640
commit
a84f762106
1 changed files with 14 additions and 1 deletions
15
src/tty.c
15
src/tty.c
|
|
@ -548,6 +548,7 @@ int tty_connect(void)
|
||||||
static bool first = true;
|
static bool first = true;
|
||||||
int status;
|
int status;
|
||||||
time_t next_timestamp = 0;
|
time_t next_timestamp = 0;
|
||||||
|
char* now = NULL;
|
||||||
|
|
||||||
/* Open tty device */
|
/* Open tty device */
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
|
|
@ -641,7 +642,19 @@ int tty_connect(void)
|
||||||
/* Print timestamp on new line, if desired. */
|
/* Print timestamp on new line, if desired. */
|
||||||
if (next_timestamp && input_char != '\n' && input_char != '\r')
|
if (next_timestamp && input_char != '\n' && input_char != '\r')
|
||||||
{
|
{
|
||||||
fprintf(stdout, ANSI_COLOR_GRAY "[%s] " ANSI_COLOR_RESET, current_time());
|
now = current_time();
|
||||||
|
fprintf(stdout, ANSI_COLOR_GRAY "[%s] " ANSI_COLOR_RESET, now);
|
||||||
|
if (option.log)
|
||||||
|
{
|
||||||
|
log_write('[');
|
||||||
|
while (*now != '\0')
|
||||||
|
{
|
||||||
|
log_write(*now);
|
||||||
|
++now;
|
||||||
|
}
|
||||||
|
log_write(']');
|
||||||
|
log_write(' ');
|
||||||
|
}
|
||||||
next_timestamp = 0;
|
next_timestamp = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue