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

Pekka Paalanen ppaalanen at gmail.com
Thu Dec 4 03:23:57 PST 2014


On Tue, 02 Dec 2014 12:12:28 -0800
Bill Spitzak <spitzak at gmail.com> wrote:

> 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.

Yeah, not a bad idea.

> 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.

Oh, I did hate those quotes, but assumed they were necessary as per
http://www.json.org/ . OTOH, I'm not so sure my outmost JSON structure
is that valid either, since I'm emitting multiple separate objects
instead of a huge array enclosing it or something.


Thanks,
pq


More information about the wayland-devel mailing list