-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
log: change date format to ISO8601-like #2386
Conversation
Oops, |
I'm thinking of creating new function like this: const char *
getFormattedTime()
{
static char buffer[32];
static char buf_datetime[21];
static char buf_millisec[4];
static char buf_timezone[6];
struct tm *now;
struct timeval tv;
int millisec;
gettimeofday(&tv, NULL);
now = localtime(&tv.tv_sec);
millisec = lrint(tv.tv_usec / 1000.0);
sprintf(buf_millisec, "%03d", millisec);
strftime(buf_datetime, sizeof(buf_datetime), "%FT%T.", now);
strftime(buf_timezone, sizeof(buf_timezone), "%z", now);
sprintf(buffer, "[%s%s%s] ", buf_datetime, buf_millisec, buf_timezone);
return buffer;
} |
ad4afe6
to
62dd78b
Compare
@aquesnel Can you also have a look? You worked hard on logging. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks fine - just one query.
Former format: "[20221007-16:36:02] " New format: "[2022-10-07T16:36:04.357+0900] "
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really like this change, thanks for making it. :-)
The tail of new datetime format was sticking out.
The tail of new datetime format was sticking out.
log: fix syslog glitch after #2386
Former format: "[20221007-16:36:02] "
New format: "[2022-10-07T16:36:04.357+0900] "
Two reasons for this change:
While I was debugging, I want to add msec for more precision. However, this will break backward compatibility. I think logs are mostly read by human so compatibility is not a serious problem. Any opinions?
The difference between the true ISO 8601 and this format is msec. The true ISO 8601 doesn't include msec.
Finally, I get the following log.
xrdp-sesman.log
xrdp.log