summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwchang0222%aol.com <devnull@localhost>2004-04-24 03:36:25 +0000
committerwchang0222%aol.com <devnull@localhost>2004-04-24 03:36:25 +0000
commit7062220fd65f425ce92f5e893805bc79b4684a51 (patch)
treeeed4bb2073b05e9aeb16744ec71febc98efae81c
parent74dac710c0aa61b52e90c27e63ab08f731c6f50f (diff)
downloadnspr-hg-7062220fd65f425ce92f5e893805bc79b4684a51.tar.gz
Bugzilla bug 236228: fixed the remaining problems with logFile == WinDebug
by moving the WinDebug handling code into the _PUT_LOG macro. The patch is contributed by timeless@bemail.org. r=wtc. Tag: NSPRPUB_PRE_4_2_CLIENT_BRANCH
-rw-r--r--pr/src/io/prlog.c27
1 files changed, 16 insertions, 11 deletions
diff --git a/pr/src/io/prlog.c b/pr/src/io/prlog.c
index b73543f8..965f0fa2 100644
--- a/pr/src/io/prlog.c
+++ b/pr/src/io/prlog.c
@@ -111,8 +111,21 @@ static PRLock *_pr_logLock;
/* Macros used to reduce #ifdef pollution */
-#if defined(_PR_USE_STDIO_FOR_LOGGING)
-#define _PUT_LOG(fd, buf, nb) {fputs(buf, fd); fflush(fd);}
+#if defined(_PR_USE_STDIO_FOR_LOGGING) && defined(XP_PC)
+#define _PUT_LOG(fd, buf, nb) \
+ PR_BEGIN_MACRO \
+ if (logFile == WIN32_DEBUG_FILE) { \
+ char savebyte = buf[nb]; \
+ buf[nb] = '\0'; \
+ OutputDebugString(buf); \
+ buf[nb] = savebyte; \
+ } else { \
+ fwrite(buf, 1, nb, fd); \
+ fflush(fd); \
+ } \
+ PR_END_MACRO
+#elif defined(_PR_USE_STDIO_FOR_LOGGING)
+#define _PUT_LOG(fd, buf, nb) {fwrite(buf, 1, nb, fd); fflush(fd);}
#elif defined(_PR_PTHREADS)
#define _PUT_LOG(fd, buf, nb) PR_Write(fd, buf, nb)
#elif defined(XP_MAC)
@@ -348,8 +361,8 @@ PR_IMPLEMENT(PRLogModuleInfo*) PR_NewLogModule(const char *name)
lm->level = PR_LOG_NONE;
lm->next = logModules;
logModules = lm;
+ _PR_SetLogModuleLevel(lm);
}
- _PR_SetLogModuleLevel(lm);
return lm;
}
@@ -407,7 +420,6 @@ PR_IMPLEMENT(void) PR_SetLogBuffering(PRIntn buffer_size)
if (logBuf)
PR_DELETE(logBuf);
- logBuf = 0;
if (buffer_size >= LINE_BUF_SIZE) {
logp = logBuf = (char*) PR_MALLOC(buffer_size);
@@ -459,14 +471,7 @@ PR_IMPLEMENT(void) PR_LogPrint(const char *fmt, ...)
_PR_LOCK_LOG();
if (logBuf == 0) {
-#ifdef XP_PC
- if ( logFile == WIN32_DEBUG_FILE)
- OutputDebugString( line );
- else
- _PUT_LOG(logFile, line, nb);
-#else
_PUT_LOG(logFile, line, nb);
-#endif
} else {
if (logp + nb > logEndp) {
_PUT_LOG(logFile, logBuf, logp - logBuf);