Commit 2cbc48f3 authored by Marius Vlad's avatar Marius Vlad

compositor: Bring back the old timestamp format for the log scope

Signed-off-by: Marius Vlad's avatarMarius Vlad <marius.vlad@collabora.com>
Reported-by: Pekka Paalanen's avatarPekka Paalanen <pekka.paalanen@collabora.com>
parent 1a3c6df5
Pipeline #53878 passed with stages
in 2 minutes and 23 seconds
......@@ -129,45 +129,46 @@ static struct weston_log_scope *log_scope;
static struct weston_log_scope *protocol_scope;
static int cached_tm_mday = -1;
static int weston_log_timestamp(void)
static char *
weston_log_timestamp(char *buf, size_t len)
{
struct timeval tv;
struct tm *brokendown_time;
char string[128];
char string_time[128];
gettimeofday(&tv, NULL);
brokendown_time = localtime(&tv.tv_sec);
if (brokendown_time == NULL)
return fprintf(weston_logfile, "[(NULL)localtime] ");
if (brokendown_time == NULL) {
snprintf(buf, len, "%s", "[(NULL)localtime] ");
return buf;
}
memset(string, 0, sizeof(string));
if (brokendown_time->tm_mday != cached_tm_mday) {
strftime(string, sizeof string, "%Y-%m-%d %Z", brokendown_time);
fprintf(weston_logfile, "Date: %s\n", string);
cached_tm_mday = brokendown_time->tm_mday;
}
strftime(string, sizeof string, "%H:%M:%S", brokendown_time);
strftime(string_time, sizeof string_time, "%H:%M:%S", brokendown_time);
if (strlen(string))
snprintf(buf, len, "Date: %s\n[%s.%03li]", string,
string_time, (tv.tv_usec / 1000));
else
snprintf(buf, len, "[%s.%03li]",
string_time, (tv.tv_usec / 1000));
return fprintf(weston_logfile, "[%s.%03li] ", string, tv.tv_usec/1000);
return buf;
}
static void
custom_handler(const char *fmt, va_list arg)
{
char timestr[128];
va_list arg2;
va_copy(arg2, arg);
weston_log_timestamp();
fprintf(weston_logfile, "libwayland: ");
vfprintf(weston_logfile, fmt, arg2);
va_end(arg2);
weston_log_scope_printf(log_scope, "%s libwayland: ",
weston_log_scope_timestamp(log_scope,
timestr, sizeof timestr));
weston_log_timestamp(timestr,
sizeof(timestr)));
weston_log_scope_vprintf(log_scope, fmt, arg);
}
......@@ -203,8 +204,8 @@ vlog(const char *fmt, va_list ap)
if (weston_log_scope_is_enabled(log_scope)) {
weston_log_scope_printf(log_scope, "%s ",
weston_log_scope_timestamp(log_scope,
timestr, sizeof timestr));
weston_log_timestamp(timestr,
sizeof(timestr)));
weston_log_scope_vprintf(log_scope, fmt, ap);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment