From b5d656058f84d9c674202630185fabb2a6dcb307 Mon Sep 17 00:00:00 2001 From: Andy Green Date: Fri, 1 Jan 2021 15:14:01 +0000 Subject: [PATCH] tags: prefix tags with pid if SS_PROXY_API Make the logs a bit easier to understand when dealing with tagged objects, when multiple client processes active, including at the proxy --- lib/core/logs.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/core/logs.c b/lib/core/logs.c index c292fd71e..b618dec24 100644 --- a/lib/core/logs.c +++ b/lib/core/logs.c @@ -53,12 +53,18 @@ __lws_lc_tag(lws_lifecycle_group_t *grp, lws_lifecycle_t *lc, const char *format, ...) { va_list ap; - int n; + int n = 1; assert(grp->tag_prefix); /* lc group must have a tag prefix string */ - n = lws_snprintf(lc->gutag, sizeof(lc->gutag) - 1u, "[%s|%lx|", - grp->tag_prefix, (unsigned long)grp->ordinal++); + lc->gutag[0] = '['; + +#if defined(LWS_WITH_SECURE_STREAMS_PROXY_API) /* ie, will have getpid if set */ + n += lws_snprintf(&lc->gutag[n], sizeof(lc->gutag) - (unsigned int)n - 1u, + "%u|", getpid()); +#endif + n += lws_snprintf(&lc->gutag[n], sizeof(lc->gutag) - (unsigned int)n - 1u, + "%s|%lx|", grp->tag_prefix, (unsigned long)grp->ordinal++); va_start(ap, format); n += vsnprintf(&lc->gutag[n], sizeof(lc->gutag) - (unsigned int)n -