compositor: Pass the entire string in one-shot when writting logger data

This fixes the situation where the same logger scope is passed multiple
times and the timestamp is being sent before the log mesasge.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
Reported-by: Pekka Paalanen <pekka.paalanen@collabora.com>
This commit is contained in:
Marius Vlad 2019-11-01 14:28:22 +02:00
parent 3a2f829983
commit ded0b77316
1 changed files with 14 additions and 4 deletions

View File

@ -199,14 +199,24 @@ weston_log_file_close(void)
static int
vlog(const char *fmt, va_list ap)
{
const char *oom = "Out of memory";
char timestr[128];
int len = 0;
char *str;
if (weston_log_scope_is_enabled(log_scope)) {
len = weston_log_scope_printf(log_scope, "%s ",
weston_log_timestamp(timestr,
sizeof timestr));
len += weston_log_scope_vprintf(log_scope, fmt, ap);
int len_va;
char *log_timestamp = weston_log_timestamp(timestr,
sizeof(timestr));
len_va = vasprintf(&str, fmt, ap);
if (len_va >= 0) {
len = weston_log_scope_printf(log_scope, "%s %s",
log_timestamp, str);
free(str);
} else {
len = weston_log_scope_printf(log_scope, "%s %s",
log_timestamp, oom);
}
}
return len;