You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by di...@apache.org on 2005/06/16 12:58:44 UTC
cvs commit: ws-axis/c/src/platforms/windows PlatformSpecificWindows.hpp
dicka 2005/06/16 03:58:44
Modified: c/src/common AxisTrace.cpp
c/src/platforms/aix PlatformSpecificAIX.hpp
c/src/platforms/os400 PlatformSpecificOS400.hpp
c/src/platforms/unix PlatformSpecificUnix.hpp
c/src/platforms/windows PlatformSpecificWindows.hpp
Log:
Include millisecond precision time and thread IDs within trace - for improved readability/usability.
PR: AXISCPP-650 and AXISCPP-651
Submitted by: Adrian Dick
Revision Changes Path
1.62 +18 -8 ws-axis/c/src/common/AxisTrace.cpp
Index: AxisTrace.cpp
===================================================================
RCS file: /home/cvs/ws-axis/c/src/common/AxisTrace.cpp,v
retrieving revision 1.61
retrieving revision 1.62
diff -u -r1.61 -r1.62
--- AxisTrace.cpp 13 May 2005 16:06:58 -0000 1.61
+++ AxisTrace.cpp 16 Jun 2005 10:58:44 -0000 1.62
@@ -257,18 +257,28 @@
{
if (!isTraceOn()) return;
- time_t current = time(NULL);
- struct tm *tm = localtime(¤t);
+
+
+ PLATFORM_TIMEB timeBuffer;
+ PLATFORM_GET_TIME_IN_MILLIS( &timeBuffer );
+ struct tm *tm = localtime(&timeBuffer.time);
- // TODO: Milliseconds
- // Use %Y not %y because %y gives a compiler warning on Linux
const int timelen=256;
char strtime[timelen];
memset(strtime,0,timelen);
- strftime(strtime,timelen,"[%d/%m/%Y %H:%M:%S:000 %Z]",tm);
-
- string text = strtime;
- text += " 1 "; // TODO: this should be the thread id
+ strftime(strtime,timelen,"[%d/%m/%Y %H:%M:%S:",tm);
+ string text = strtime;
+
+ char millis[5];
+ sprintf(millis, "%03u", timeBuffer.millitm);
+ text += millis;
+
+ strftime(strtime, timelen, " %Z]", tm);
+ text += strtime;
+
+ char threadID[20];
+ sprintf(threadID, " %lu ", PLATFORM_GET_THREAD_ID);
+ text += threadID;
if (NULL==classname) text += "-";
else text += classname;
1.16 +13 -0 ws-axis/c/src/platforms/aix/PlatformSpecificAIX.hpp
Index: PlatformSpecificAIX.hpp
===================================================================
RCS file: /home/cvs/ws-axis/c/src/platforms/aix/PlatformSpecificAIX.hpp,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- PlatformSpecificAIX.hpp 24 May 2005 13:35:34 -0000 1.15
+++ PlatformSpecificAIX.hpp 16 Jun 2005 10:58:44 -0000 1.16
@@ -75,6 +75,8 @@
// Miscellaneous
// =============================================================
#include <sys/time.h>
+#include <sys/timeb.h>
+#include <pthread.h>
#include <unistd.h>
#define PLATFORM_SLEEP(x) sleep(0);
@@ -98,6 +100,17 @@
#define PLATFORM_GET_ERROR_MESSAGE(errorNumber) new string(strerror(errorNumber));
/**
+ * Platform specific method to obtain current thread ID
+ */
+#define PLATFORM_GET_THREAD_ID pthread_self()
+
+/**
+ * Platform specific method to obtain current time in milli seconds
+ */
+#define PLATFORM_GET_TIME_IN_MILLIS ftime
+#define PLATFORM_TIMEB timeb
+
+/**
* type to be used for 64bit integers
*/
#define LONGLONG long long
1.17 +12 -0 ws-axis/c/src/platforms/os400/PlatformSpecificOS400.hpp
Index: PlatformSpecificOS400.hpp
===================================================================
RCS file: /home/cvs/ws-axis/c/src/platforms/os400/PlatformSpecificOS400.hpp,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- PlatformSpecificOS400.hpp 23 May 2005 20:05:40 -0000 1.16
+++ PlatformSpecificOS400.hpp 16 Jun 2005 10:58:44 -0000 1.17
@@ -76,6 +76,7 @@
// Miscellaneous
// =============================================================
#include <sys/time.h>
+#include <sys/timeb.h>
#include <unistd.h>
#include <errno.h>
#define PLATFORM_SLEEP(x) sleep(0);
@@ -98,6 +99,17 @@
#define PLATFORM_GET_ERROR_MESSAGE(errorNumber) new string(strerror(errorNumber));
/**
+ * Platform specific method to obtain current thread ID
+ */
+#define PLATFORM_GET_THREAD_ID pthread_self()
+
+/**
+ * Platform specific method to obtain current time in milli seconds
+ */
+#define PLATFORM_GET_TIME_IN_MILLIS ftime
+#define PLATFORM_TIMEB timeb
+
+/**
* type to be used for 64bit integers
*/
#define LONGLONG long long
1.21 +12 -0 ws-axis/c/src/platforms/unix/PlatformSpecificUnix.hpp
Index: PlatformSpecificUnix.hpp
===================================================================
RCS file: /home/cvs/ws-axis/c/src/platforms/unix/PlatformSpecificUnix.hpp,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- PlatformSpecificUnix.hpp 24 May 2005 13:35:34 -0000 1.20
+++ PlatformSpecificUnix.hpp 16 Jun 2005 10:58:44 -0000 1.21
@@ -76,6 +76,7 @@
// Miscellaneous
// =============================================================
#include <sys/time.h>
+#include <sys/timeb.h>
#include <unistd.h>
#include <errno.h>
#define PLATFORM_SLEEP(x) sleep(0);
@@ -97,6 +98,17 @@
#define PLATFORM_GET_ERROR_MESSAGE(errorNumber) new string(strerror(errorNumber));
/**
+ * Platform specific method to obtain current thread ID
+ */
+#define PLATFORM_GET_THREAD_ID pthread_self()
+
+/**
+ * Platform specific method to obtain current time in milli seconds
+ */
+#define PLATFORM_GET_TIME_IN_MILLIS ftime
+#define PLATFORM_TIMEB timeb
+
+/**
* type to be used for 64bit integers
*/
#define LONGLONG long long
1.20 +11 -0 ws-axis/c/src/platforms/windows/PlatformSpecificWindows.hpp
Index: PlatformSpecificWindows.hpp
===================================================================
RCS file: /home/cvs/ws-axis/c/src/platforms/windows/PlatformSpecificWindows.hpp,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- PlatformSpecificWindows.hpp 25 May 2005 16:03:16 -0000 1.19
+++ PlatformSpecificWindows.hpp 16 Jun 2005 10:58:44 -0000 1.20
@@ -23,6 +23,7 @@
#define _WINSOCKAPI_ /* Prevent inclusion of winsock.h in windows.h */
#include <windows.h>
#include <string>
+#include <sys/timeb.h>
// =============================================================
// Default paths to shared library/DLLs and files
@@ -101,6 +102,16 @@
#define PRINTF_LONGLONG_FORMAT_SPECIFIER "%I64d"
#define PRINTF_LONGLONG_FORMAT_SPECIFIER_CHARS "I64d"
+/**
+ * Platform specific method to obtain current thread ID
+ */
+#define PLATFORM_GET_THREAD_ID GetCurrentThreadId()
+
+/**
+ * Platform specific method to obtain current time in milli seconds
+ */
+#define PLATFORM_GET_TIME_IN_MILLIS _ftime
+#define PLATFORM_TIMEB _timeb
std::string* getPlatformErrorMessage(long errorNumber);