-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi Mihai,
[...]
>>Any comments?
>
>
> Hi Andreas
>
> I have none, sounds like a better solution from my point of view (hope
Ok, great; I found one meanwhile though ;-)
The "%pt" format of apr_snprintf() requires the *address* of
the apr_os_thread_t variable. Strangely the unittests succeeded
on my desktop linux box, but not during the nightly build on my
server ...
Corrected patch is attached.
Best Regards,
Andreas
- --
Andreas Fester
mailto:[EMAIL PROTECTED]
WWW: http://www.littletux.net
ICQ: 326674288
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
iD8DBQFDZd1CZ3bQVzeW+rsRAraOAJ9PWgzYZxBPotPeyuw9EmAbY9EAWQCgt/Cd
k21+TIwlX77rCuz7SLHiM7Y=
=M9UR
-----END PGP SIGNATURE-----
diff -urN log4cxx-0.9.8.old/include/log4cxx/helpers/stringhelper.h
log4cxx-0.9.8/include/log4cxx/helpers/stringhelper.h
--- log4cxx-0.9.8.old/include/log4cxx/helpers/stringhelper.h 2005-10-23
03:06:24.000000000 +0200
+++ log4cxx-0.9.8/include/log4cxx/helpers/stringhelper.h 2005-10-29
12:47:37.000000000 +0200
@@ -53,8 +53,6 @@
static LogString toString(bool val);
- static LogString formatHex(const void* handle);
-
static std::string toLowerCase(const std::string& s);
static bool getline(std::string& buf, std::string& line);
diff -urN log4cxx-0.9.8.old/include/log4cxx/private/log4cxx_private.h
log4cxx-0.9.8/include/log4cxx/private/log4cxx_private.h
--- log4cxx-0.9.8.old/include/log4cxx/private/log4cxx_private.h 2005-10-23
03:07:57.000000000 +0200
+++ log4cxx-0.9.8/include/log4cxx/private/log4cxx_private.h 2005-10-29
12:47:55.000000000 +0200
@@ -43,11 +43,6 @@
typedef log4cxx_int64_t log4cxx_time_t;
typedef int log4cxx_status_t;
-//
-// unsigned int same size as void*
-//
-typedef unsigned int log4cxx_intptr_t;
-
#define LOG4CXX_LOCALE_ENCODING_UTF8 0
#define LOG4CXX_LOCALE_ENCODING_ISO_8859_1 0
#define LOG4CXX_LOCALE_ENCODING_US_ASCII 0
diff -urN log4cxx-0.9.8.old/src/loggingevent.cpp
log4cxx-0.9.8/src/loggingevent.cpp
--- log4cxx-0.9.8.old/src/loggingevent.cpp 2005-10-15 09:34:35.000000000
+0200
+++ log4cxx-0.9.8/src/loggingevent.cpp 2005-10-29 12:45:39.000000000 +0200
@@ -26,9 +26,11 @@
#include <log4cxx/helpers/socket.h>
#include <log4cxx/helpers/aprinitializer.h>
#include <log4cxx/helpers/threadspecificdata.h>
+#include <log4cxx/helpers/transcoder.h>
#include <apr_time.h>
#include <apr_portable.h>
+#include <apr_strings.h>
#include <log4cxx/helpers/stringhelper.h>
using namespace log4cxx;
@@ -192,7 +194,15 @@
const LogString LoggingEvent::getCurrentThreadName() {
#if APR_HAS_THREADS
- return StringHelper::formatHex((const void*) apr_os_thread_current());
+ apr_os_thread_t threadId = apr_os_thread_current();
+
+ // apr_os_thread_t encoded in HEX takes needs as many characters
+ // as two times the size of the type, plus an additional null byte
+ char result[sizeof(apr_os_thread_t) * 2 + 1];
+ apr_snprintf(result, sizeof result, "%pt", &threadId);
+
+ LOG4CXX_DECODE_CHAR(str, (const char*) result);
+ return LOG4CXX_STR("0x") + str;
#else
return LOG4CXX_STR("0x00000000");
#endif
diff -urN log4cxx-0.9.8.old/src/stringhelper.cpp
log4cxx-0.9.8/src/stringhelper.cpp
--- log4cxx-0.9.8.old/src/stringhelper.cpp 2005-10-23 03:06:24.000000000
+0200
+++ log4cxx-0.9.8/src/stringhelper.cpp 2005-10-29 12:47:15.000000000 +0200
@@ -281,21 +281,6 @@
#endif
-
-LogString StringHelper::formatHex(const void* ptr) {
- const logchar* hexdigits = LOG4CXX_STR("0123456789ABCDEF");
- log4cxx_intptr_t iptr = (log4cxx_intptr_t) ptr;
- int width = sizeof(ptr)*2 + 2;
- LogString s(width, LOG4CXX_STR('x'));
- s[0] = LOG4CXX_STR('0');
- for(int i = width - 1; i >= 2; i--) {
- s[i] = hexdigits[iptr & 0x0F];
- iptr = iptr >> 4;
- }
- return s;
-}
-
-
LogString StringHelper::format(const LogString& pattern, const
std::vector<LogString>& params) {
LogString result;
diff -urN log4cxx-0.9.8.old/tests/src/patternlayouttest.cpp
log4cxx-0.9.8/tests/src/patternlayouttest.cpp
--- log4cxx-0.9.8.old/tests/src/patternlayouttest.cpp 2005-10-15
09:34:41.000000000 +0200
+++ log4cxx-0.9.8/tests/src/patternlayouttest.cpp 2005-10-29
12:27:53.000000000 +0200
@@ -283,7 +283,7 @@
//
// combo of relative time and thread identifier
// (the \\\\1 preserve a leading space)
- Filter filter2(".*0x[0-9A-F]*]", "[main]");
+ Filter filter2(".*0x[0-9a-f]*]", "[main]");
std::vector<Filter *> filters;
diff -urN log4cxx-0.9.8.old/tests/src/util/threadfilter.cpp
log4cxx-0.9.8/tests/src/util/threadfilter.cpp
--- log4cxx-0.9.8.old/tests/src/util/threadfilter.cpp 2005-10-15
09:34:41.000000000 +0200
+++ log4cxx-0.9.8/tests/src/util/threadfilter.cpp 2005-10-29
12:10:22.000000000 +0200
@@ -19,4 +19,4 @@
using namespace log4cxx;
using namespace log4cxx::helpers;
-ThreadFilter::ThreadFilter() : Filter("\\[0x[0-9A-F]*]", "\\[main]") {}
+ThreadFilter::ThreadFilter() : Filter("\\[0x[0-9a-f]*]", "\\[main]") {}
diff -urN log4cxx-0.9.8.old/tests/src/util/xmlthreadfilter.cpp
log4cxx-0.9.8/tests/src/util/xmlthreadfilter.cpp
--- log4cxx-0.9.8.old/tests/src/util/xmlthreadfilter.cpp 2005-10-15
09:34:41.000000000 +0200
+++ log4cxx-0.9.8/tests/src/util/xmlthreadfilter.cpp 2005-10-29
12:30:59.000000000 +0200
@@ -20,5 +20,5 @@
using namespace log4cxx::helpers;
XMLThreadFilter::XMLThreadFilter()
- : Filter("0x[0-9A-F]*", "main") {
+ : Filter("0x[0-9a-f]*", "main") {
}