On Fri, 20 Jul 2018 20:03:24 +0100
Daniel Stone <[email protected]> wrote:

> From: Pekka Paalanen <[email protected]>
> 
> weston_debug is both a libweston API for relaying debugging messages,
> and the compositor-debug wayland protocol implementation for accessing those
> debug messages from a Wayland client.
> 
> weston_debug_compositor_{create,destroy}() are private API, hence not
> exported.
> 
> Signed-off-by: Pekka Paalanen <[email protected]>
> 
> append the debug scope name along with the timestamp in
> weston_debug_scope_timestamp API
> 
> Signed-off-by: Maniraj Devadoss <[email protected]>
> Reviewed-by: Pekka Paalanen <[email protected]>
> 
> Add explicit advertisement of debug scope names.
> 
> Signed-off-by: Daniel Stone <[email protected]>
> ---
>  Makefile.am              |   2 +
>  libweston/compositor.c   |   6 +
>  libweston/compositor.h   |   9 +
>  libweston/weston-debug.c | 723 +++++++++++++++++++++++++++++++++++++++
>  libweston/weston-debug.h | 107 ++++++
>  5 files changed, 847 insertions(+)
>  create mode 100644 libweston/weston-debug.c
>  create mode 100644 libweston/weston-debug.h

...

> +/** Format current time as a string
> + * and append the debug scope name to it
> + *
> + * \param scope[in] debug scope.
> + * \param buf[out] Buffer to store the string.
> + * \param len Available size in the buffer in bytes.
> + * \return \c buf
> + *
> + * Reads the current local wall-clock time and formats it into a string.
> + * and append the debug scope name to it.
> + * The string is nul-terminated, even if truncated.
> + */
> +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);
> +
> +     return buf;
> +}

Hi,

realized something when looking at the "log" debug scope patch:
weston_debug_scope_timestamp() should probably be resilient against
scope == NULL, all the other functions already are.

weston_log gets initialized early, but the log debug scope gets
initialized after the compositor. If something logs something between
those two...


Thanks,
pq

Attachment: pgphjGy8Cnsw7.pgp
Description: OpenPGP digital signature

_______________________________________________
wayland-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/wayland-devel

Reply via email to