mirror of
https://github.com/tmate-io/tmate-ssh-server.git
synced 2020-11-18 19:53:51 -08:00
Put the time in the log messages
This commit is contained in:
parent
fb733d9433
commit
2e69b5c692
12
log.c
12
log.c
@ -80,12 +80,22 @@ log_close(void)
|
|||||||
void
|
void
|
||||||
log_vwrite(const char *msg, va_list ap)
|
log_vwrite(const char *msg, va_list ap)
|
||||||
{
|
{
|
||||||
|
char time_str[100];
|
||||||
|
time_t now;
|
||||||
|
struct tm *tm;
|
||||||
|
|
||||||
char *fmt;
|
char *fmt;
|
||||||
|
|
||||||
if (log_file == NULL)
|
if (log_file == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (asprintf(&fmt, "[%s] %s\n", tmate_session_token, msg) == -1)
|
/* XXX Should we do UTC instead of local time? */
|
||||||
|
now = time(NULL);
|
||||||
|
tm = localtime(&now);
|
||||||
|
|
||||||
|
strftime(time_str, sizeof(time_str), "%Y-%m-%d %H:%M:%S", tm);
|
||||||
|
|
||||||
|
if (asprintf(&fmt, "%s [%s] %s\n", time_str, tmate_session_token, msg) == -1)
|
||||||
exit(1);
|
exit(1);
|
||||||
if (vfprintf(log_file, fmt, ap) == -1)
|
if (vfprintf(log_file, fmt, ap) == -1)
|
||||||
exit(1);
|
exit(1);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user