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>
dev
Marius Vlad 5 years ago
parent 3a2f829983
commit ded0b77316
  1. 18
      compositor/main.c

@ -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;

Loading…
Cancel
Save