From 5b3a9d83fd51028aa519714f68037e7a363ed0fc Mon Sep 17 00:00:00 2001 From: Jeff Trawick Date: Wed, 31 Aug 2005 12:34:07 +0000 Subject: [PATCH] mod_log_config: %{hextid}P will log the thread id in hex with APR versions 1.2.0 or higher. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@265033 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES | 3 +++ docs/manual/mod/mod_log_config.xml | 4 +++- modules/loggers/mod_log_config.c | 12 ++++++++++-- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/CHANGES b/CHANGES index c0135e5328..3f2caf8ac6 100644 --- a/CHANGES +++ b/CHANGES @@ -2,6 +2,9 @@ Changes with Apache 2.3.0 [Remove entries to the current 2.0 and 2.2 section below, when backported] + *) mod_log_config: %{hextid}P will log the thread id in hex with APR + versions 1.2.0 or higher. [Jeff Trawick] + *) mod_cgid: Refuse to work on Solaris 10 due to OS bugs. PR 34264. [Justin Erenkrantz] diff --git a/docs/manual/mod/mod_log_config.xml b/docs/manual/mod/mod_log_config.xml index 2f623ca386..d385267159 100644 --- a/docs/manual/mod/mod_log_config.xml +++ b/docs/manual/mod/mod_log_config.xml @@ -132,7 +132,9 @@ %{format}P The process ID or thread id of the child that serviced the - request. Valid formats are pid and tid. + request. Valid formats are pid, tid, + and hextid. hextid requires APR 1.2.0 or + higher. %q diff --git a/modules/loggers/mod_log_config.c b/modules/loggers/mod_log_config.c index b8900683e6..718441d714 100644 --- a/modules/loggers/mod_log_config.c +++ b/modules/loggers/mod_log_config.c @@ -650,13 +650,21 @@ static const char *log_pid_tid(request_rec *r, char *a) 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, +#if APR_MAJOR_VERSION > 1 || (APR_MAJOR_VERSION == 1 && APR_MINOR_VERSION >= 2) + /* APR can format a thread id in hex */ + *a == 'h' ? "%pt" : "%pT", +#else + /* APR is missing the feature, so always use decimal */ + "%pT", +#endif + &tid); } /* bogus format */ return a; -- 2.40.0