[PATCH weston v2 2/2] compositor: Implement JSON-timeline logging

Bill Spitzak spitzak at gmail.com
Tue Dec 2 12:12:28 PST 2014


On 12/02/2014 05:45 AM, Pekka Paalanen wrote:
> From: Pekka Paalanen <pekka.paalanen at collabora.co.uk>

> +	if (!s->get_label || s->get_label(s, d, sizeof(d)) < 0) {
> +		d[0] = '\0';
> +		q = "";
> +	}
> +
> +	fprintf(ctx->out, "{ \"id\":%u, "
> +		"\"type\":\"weston_surface\", "
> +		"\"desc\":%s%s%s%s }\n",
> +		s->timeline.id, q, d[0] ? d : "null", q, mainstr);

I think you should make an emit(FILE*, const char*) function that prints 
a quoted string or null, instead of doing this repeatedly. Such a 
function could also convert non-printable characters to escape sequences.

I think also you should ignore strict JSON and not put quotes around the 
keywords. It makes the output a lot easier to read and most libraries 
handle it.



More information about the wayland-devel mailing list