[PATCH weston v5 03/14] libweston: add weston_debug API and implementation
Pekka Paalanen
ppaalanen at gmail.com
Mon Aug 6 11:15:38 UTC 2018
On Fri, 20 Jul 2018 20:03:24 +0100
Daniel Stone <daniels at collabora.com> wrote:
> From: Pekka Paalanen <pq at iki.fi>
>
> 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 <pq at iki.fi>
>
> append the debug scope name along with the timestamp in
> weston_debug_scope_timestamp API
>
> Signed-off-by: Maniraj Devadoss <Maniraj.Devadoss at in.bosch.com>
> Reviewed-by: Pekka Paalanen <pekka.paalanen at collabora.co.uk>
>
> Add explicit advertisement of debug scope names.
>
> Signed-off-by: Daniel Stone <daniels at collabora.com>
> ---
> 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
-------------- 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/20180806/128fcd0a/attachment.sig>
More information about the wayland-devel
mailing list