|
|
|
@ -134,37 +134,6 @@ static struct weston_log_scope *log_scope; |
|
|
|
|
static struct weston_log_scope *protocol_scope; |
|
|
|
|
static int cached_tm_mday = -1; |
|
|
|
|
|
|
|
|
|
static char * |
|
|
|
|
weston_log_timestamp(char *buf, size_t len) |
|
|
|
|
{ |
|
|
|
|
struct timeval tv; |
|
|
|
|
struct tm *brokendown_time; |
|
|
|
|
char datestr[128]; |
|
|
|
|
char timestr[128]; |
|
|
|
|
|
|
|
|
|
gettimeofday(&tv, NULL); |
|
|
|
|
|
|
|
|
|
brokendown_time = localtime(&tv.tv_sec); |
|
|
|
|
if (brokendown_time == NULL) { |
|
|
|
|
snprintf(buf, len, "%s", "[(NULL)localtime] "); |
|
|
|
|
return buf; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
memset(datestr, 0, sizeof(datestr)); |
|
|
|
|
if (brokendown_time->tm_mday != cached_tm_mday) { |
|
|
|
|
strftime(datestr, sizeof(datestr), "Date: %Y-%m-%d %Z\n", |
|
|
|
|
brokendown_time); |
|
|
|
|
cached_tm_mday = brokendown_time->tm_mday; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
strftime(timestr, sizeof(timestr), "%H:%M:%S", brokendown_time); |
|
|
|
|
/* if datestr is empty it prints only timestr*/ |
|
|
|
|
snprintf(buf, len, "%s[%s.%03li]", datestr, |
|
|
|
|
timestr, (tv.tv_usec / 1000)); |
|
|
|
|
|
|
|
|
|
return buf; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static void |
|
|
|
|
custom_handler(const char *fmt, va_list arg) |
|
|
|
|
{ |
|
|
|
@ -172,7 +141,7 @@ custom_handler(const char *fmt, va_list arg) |
|
|
|
|
|
|
|
|
|
weston_log_scope_printf(log_scope, "%s libwayland: ", |
|
|
|
|
weston_log_timestamp(timestr, |
|
|
|
|
sizeof(timestr))); |
|
|
|
|
sizeof(timestr), &cached_tm_mday)); |
|
|
|
|
weston_log_scope_vprintf(log_scope, fmt, arg); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -218,7 +187,8 @@ vlog(const char *fmt, va_list ap) |
|
|
|
|
if (weston_log_scope_is_enabled(log_scope)) { |
|
|
|
|
int len_va; |
|
|
|
|
char *log_timestamp = weston_log_timestamp(timestr, |
|
|
|
|
sizeof(timestr)); |
|
|
|
|
sizeof(timestr), |
|
|
|
|
&cached_tm_mday); |
|
|
|
|
len_va = vasprintf(&str, fmt, ap); |
|
|
|
|
if (len_va >= 0) { |
|
|
|
|
len = weston_log_scope_printf(log_scope, "%s %s", |
|
|
|
|