Author: mturk
Date: Mon Jan 18 18:46:22 2010
New Revision: 900507
URL: http://svn.apache.org/viewvc?rev=900507&view=rev
Log:
Add time pid and tid to the debug message
Modified:
commons/sandbox/runtime/trunk/src/main/native/os/unix/exec.c
commons/sandbox/runtime/trunk/src/main/native/os/unix/uutils.c
commons/sandbox/runtime/trunk/src/main/native/os/win32/wutil.c
Modified: commons/sandbox/runtime/trunk/src/main/native/os/unix/exec.c
URL:
http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/unix/exec.c?rev=900507&r1=900506&r2=900507&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/unix/exec.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/unix/exec.c Mon Jan 18
18:46:22 2010
@@ -279,7 +279,7 @@
goto child_cleanup;
}
if (pipes[PIPE_STDERR_WRS] == -1) {
- if (ep->flags & ACR_NUL_STDERR) {
+ if (ep->flags & ACR_PROC_NUL_STDERR) {
pipes[PIPE_STDERR_WRS] = nullpipe(O_WRONLY, -1);
if (pipes[PIPE_STDERR_WRS] == -1) {
rc = ACR_GET_OS_ERROR();
@@ -293,7 +293,7 @@
rc = ACR_GET_OS_ERROR();
goto child_cleanup;
}
- if (pipes[PIPE_STDERR_WRS] != pipes[PIPE_STDOUT_WRS]
+ if (pipes[PIPE_STDERR_WRS] != pipes[PIPE_STDOUT_WRS])
i_close(&pipes[PIPE_STDERR_WRS]);
i_close(&pipes[PIPE_STDOUT_WRS]);
/* Close all descriptors except our pipes
Modified: commons/sandbox/runtime/trunk/src/main/native/os/unix/uutils.c
URL:
http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/unix/uutils.c?rev=900507&r1=900506&r2=900507&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/unix/uutils.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/unix/uutils.c Mon Jan 18
18:46:22 2010
@@ -29,16 +29,34 @@
#include <sys/time.h>
#if defined(DEBUG) || defined(_DEBUG)
+#if defined(LINUX)
+#include <sys/syscall.h>
+#include <sys/types.h>
+#define ACR_GETTID() (unsigned int)syscall(SYS_gettid)
+#else
+#define ACR_GETTID() (unsigned int)(((ptrdiff_t)pthread_self()) >> 4)
+#endif
+
void acr_dbprintf(const char *file, int line, const char *format, ...)
{
- FILE *stream;
+ FILE *stream;
+ time_t timevar;
+ struct tm *lt;
va_list ap;
if (!(stream = fopen("/dev/tty", "a")))
return;
+
+ time(&timevar);
+ lt = localtime(&timevar);
+
+ fprintf(stream, "[%d:%u] [%d-%.2d-%.2d %.2d:%.2d:%.2d]: ",
+ getpid(), ACR_GETTID(),
+ lt->tm_year + 1900, lt->tm_mon + 1, lt->tm_mday,
+ lt->tm_hour, lt->tm_min, lt->tm_sec);
if (file) {
const char *fn = ACR_FilePathNameGet(file);
- fprintf(stream, "[%-10s %4d] ", fn, line);
+ fprintf(stream, "%s:%d: ", fn, line);
}
va_start(ap, format);
vfprintf(stream, format, ap);
Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/wutil.c
URL:
http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/wutil.c?rev=900507&r1=900506&r2=900507&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/win32/wutil.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/win32/wutil.c Mon Jan 18
18:46:22 2010
@@ -27,28 +27,46 @@
#include "acr_arch.h"
#include <direct.h>
+#include <time.h>
#define NON_UNC_PATH_LENGTH 248
#if defined(DEBUG) || defined(_DEBUG)
void acr_dbprintf(const char *file, int line, const char *format, ...)
{
- char buf[ACR_HBUFF_SIZ];
- char fmt[ACR_HBUFF_SIZ];
- char *bp = buf;
+ char buff[ACR_HBUFF_SIZ];
+ char *bp = buff;
+ char *ep;
+ time_t timevar;
+ struct tm *lt;
va_list ap;
- va_start(ap, format);
- _vsnprintf(buf, sizeof(buf), format, ap);
- va_end(ap);
+ time(&timevar);
+ lt = localtime(&timevar);
+ ep = bp + ACR_HBUFF_SIZ;
+ snprintf(bp, (size_t)(ep - bp),
+ "[%u:%u] [%d-%.2d-%.2d %.2d:%.2d:%.2d]: ",
+ GetCurrentProcessId(), GetCurrentThreadId(),
+ lt->tm_year + 1900, lt->tm_mon + 1, lt->tm_mday,
+ lt->tm_hour, lt->tm_min, lt->tm_sec);
+ bp += strlen(buf);
if (file) {
- const char *fn = ACR_FilePathNameGet(file);
- snprintf(fmt, ACR_HBUFF_LEN, "[%-6d %-10s %4d] %s",
- GetCurrentProcessId(), fn, line, buf);
- bp = fmt;
+ snprintf(bp, (size_t)(ep - bp),
+ "%s:%d: ", fn, line);
+ bp += strlen(buf);
}
- OutputDebugStringA(bp);
- fputs(bp, stdout);
+ va_start(ap, format);
+ _vsnprintf(bp, (size_t)(ep - bp), format, ap);
+ va_end(ap);
+ if ((ep = strchr(buff, ':'))) {
+ /* DbgView already displays process id
+ * Forward to the thread id.
+ */
+ *ep = '[';
+ OutputDebugStringA(ep);
+ *ep = ':';
+ }
+ fputs(buff, stdout);
fputc('\n', stdout);
fflush(stdout);
}
@@ -620,3 +638,4 @@
else
return wcsdup(buff);
}
+