Use monotonic() instead of time of day for logging

Time of day is verbose and I have never found it to be of any use
This commit is contained in:
Kovid Goyal 2024-03-26 13:32:07 +05:30
parent ede332fecf
commit bb45062ef6
No known key found for this signature in database
GPG key ID: 06BC317B515ACE7C

View file

@ -53,17 +53,7 @@ log_error(const char *fmt, ...) {
END_ALLOW_CASE_RANGE
if (!use_os_log) { // Apple's os_log already records timestamps
struct timeval tv;
gettimeofday(&tv, NULL);
struct tm stack_tmp;
struct tm *tmp = localtime_r(&tv.tv_sec, &stack_tmp);
if (tmp) {
char tbuf[256] = {0}, buf[256] = {0};
if (strftime(buf, sizeof(buf), "%j %H:%M:%S.%%06u", tmp) != 0) {
snprintf(tbuf, sizeof(tbuf), buf, tv.tv_usec);
fprintf(stderr, "[%s] ", tbuf);
}
}
fprintf(stderr, "[%.3f] ", monotonic_t_to_s_double(monotonic()));
}
#ifdef __APPLE__
if (use_os_log) os_log(OS_LOG_DEFAULT, "%{public}s", sanbuf);