[PATCH weston v4 2/9] libweston: add weston_debug API and implementation

Pekka Paalanen ppaalanen at gmail.com
Mon Oct 23 10:54:51 UTC 2017


On Mon, 23 Oct 2017 12:34:47 +0200
Daniel Stone <daniel at fooishbar.org> wrote:

> Hi,
> 
> On 12 October 2017 at 13:13, Emre Ucan <eucan at de.adit-jv.com> wrote:
> > +WL_EXPORT char *
> > +weston_debug_scope_timestamp(struct weston_debug_scope *scope,
> > +                            char *buf, size_t len)
> > +{
> > +       struct timeval tv;
> > +       struct tm *bdt;
> > +       char string[128];
> > +       size_t ret = 0;
> > +
> > +       gettimeofday(&tv, NULL);
> > +
> > +       bdt = localtime(&tv.tv_sec);
> > +       if (bdt)
> > +               ret = strftime(string, sizeof string,
> > +                              "%Y-%m-%d %H:%M:%S", bdt);
> > +
> > +       if (ret > 0)
> > +               snprintf(buf, len, "[%s.%03ld][%s]", string,
> > +                        tv.tv_usec / 1000, scope->name);
> > +       else
> > +               snprintf(buf, len, "[?][%s]", scope->name);  
> 
> I would very much not like to see formatted time in the debug scopes.
> Can we please just use a raw microsecond value? Ultimately I would
> like to see tools parse these files, but trying to parse formatted
> times is a nightmare.

Hm, that is very much contrary to my original intentions. I hate
reading raw timestamps, they are difficult to make sense of. I also
didn't intend the output to be machine-parsed, at least not the streams
that use this function for timestamps. (Emitting timestamps is
completely optional.)

The usual use case for these is that I am reading through the log
myself and that is what I optimized for: human readability.

I suppose we would need a dual-mode framework to support both
human-readable and machine-readable output, because I cannot see myself
updating a post-processing parser every time I add some new debug prints.

This is literally supposed to be a dynamic printf equivalent.


Thanks,
pq
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
URL: <https://lists.freedesktop.org/archives/wayland-devel/attachments/20171023/c075c2d8/attachment.sig>


More information about the wayland-devel mailing list