You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Jeff Trawick <tr...@gmail.com> on 2005/08/27 17:12:24 UTC

mod_log_config: log thread id in hex

%{tid}P gets you thread id in decimal now.
%{hextid}P would show it in hex using relatively new apr_sprintf()
format, added in 1.2.0.

Re: mod_log_config: log thread id in hex

Posted by Justin Erenkrantz <ju...@erenkrantz.com>.
On Tue, Aug 30, 2005 at 11:28:37AM +0100, Joe Orton wrote:
> On Sat, Aug 27, 2005 at 11:12:24AM -0400, Jeff Trawick wrote:
> > %{tid}P gets you thread id in decimal now.
> > %{hextid}P would show it in hex using relatively new apr_sprintf()
> > format, added in 1.2.0.
> 
> Seems fine except that it introduces a softish dependency on apr >= 
> 1.2.0 which is not enforced by configure (which allows use of any apr 
> 1.x).

Agreed.  I'd guess we should make that conditional on having apr 1.2.0+.
With lower versions of APR, don't support that tag.  -- justin

Re: mod_log_config: log thread id in hex

Posted by Joe Orton <jo...@redhat.com>.
On Sat, Aug 27, 2005 at 11:12:24AM -0400, Jeff Trawick wrote:
> %{tid}P gets you thread id in decimal now.
> %{hextid}P would show it in hex using relatively new apr_sprintf()
> format, added in 1.2.0.

Seems fine except that it introduces a softish dependency on apr >= 
1.2.0 which is not enforced by configure (which allows use of any apr 
1.x).

> Index: modules/loggers/mod_log_config.c
> ===================================================================
> --- modules/loggers/mod_log_config.c	(revision 240100)
> +++ modules/loggers/mod_log_config.c	(working copy)
> @@ -650,13 +650,15 @@
>      if (*a == '\0' || !strcmp(a, "pid")) {
>          return apr_psprintf(r->pool, "%" APR_PID_T_FMT, getpid());
>      }
> -    else if (!strcmp(a, "tid")) {
> +    else if (!strcmp(a, "tid") || !strcmp(a, "hextid")) {
>  #if APR_HAS_THREADS
>          apr_os_thread_t tid = apr_os_thread_current();
>  #else
>          int tid = 0; /* APR will format "0" anyway but an arg is needed */
>  #endif
> -        return apr_psprintf(r->pool, "%pT", &tid);
> +        return apr_psprintf(r->pool,
> +                            *a == 'h' ? "%pt" : "%pT",
> +                            &tid);
>      }
>      /* bogus format */
>      return a;