commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject svn commit: r1025823 - in /commons/proper/daemon/trunk: RELEASE-NOTES.txt src/native/windows/src/log.c
Date Thu, 21 Oct 2010 05:06:57 GMT
Author: mturk
Date: Thu Oct 21 05:06:56 2010
New Revision: 1025823

URL: http://svn.apache.org/viewvc?rev=1025823&view=rev
Log:
DAEMON-181 Use DOS line endings as log line seperators

Modified:
    commons/proper/daemon/trunk/RELEASE-NOTES.txt
    commons/proper/daemon/trunk/src/native/windows/src/log.c

Modified: commons/proper/daemon/trunk/RELEASE-NOTES.txt
URL: http://svn.apache.org/viewvc/commons/proper/daemon/trunk/RELEASE-NOTES.txt?rev=1025823&r1=1025822&r2=1025823&view=diff
==============================================================================
--- commons/proper/daemon/trunk/RELEASE-NOTES.txt (original)
+++ commons/proper/daemon/trunk/RELEASE-NOTES.txt Thu Oct 21 05:06:56 2010
@@ -71,7 +71,7 @@ NEW FEATURES:
 BUG FIXES:
 
 1.0.4: DAEMON-95, DAEMON-171, DAEMON-100, DAEMON-164, DAEMON-165, DAEMON-175,
-       DAEMON-177, DAEMON-150, DAEMON-163, DAEMON-182
+       DAEMON-177, DAEMON-150, DAEMON-163, DAEMON-182, DAEMON-181
 
 1.0.3: DAEMON-108, DAEMON-128, DAEMON-139, DAEMON-143, DAEMON-148,
        DAEMON-135, DAEMON-155, DAEMON-159, DAEMON-161, DAEMON-145, DAEMON-146,

Modified: commons/proper/daemon/trunk/src/native/windows/src/log.c
URL: http://svn.apache.org/viewvc/commons/proper/daemon/trunk/src/native/windows/src/log.c?rev=1025823&r1=1025822&r2=1025823&view=diff
==============================================================================
--- commons/proper/daemon/trunk/src/native/windows/src/log.c (original)
+++ commons/proper/daemon/trunk/src/native/windows/src/log.c Thu Oct 21 05:06:56 2010
@@ -18,7 +18,7 @@
 #include "private.h"
 #include <stdio.h>
 
-#define LINE_SEP    "\n"
+#define LINE_SEP    "\r\n"
 #define LOGF_EXT    L".%04d-%02d-%02d.log"
 
 static LPCSTR _log_level[] = {
@@ -247,7 +247,7 @@ apxLogWrite(
     ...)
 {
     va_list args;
-    CHAR    buffer[1024+32];
+    CHAR    buffer[1024+32] = "";
     LPSTR   szBp;
     int     len = 0;
     LPCSTR  f = szFile;
@@ -274,7 +274,9 @@ apxLogWrite(
         if(f != szFile)
             f++;
     }
-    szBp = &buffer[0];
+    else
+        f = "";
+    szBp = buffer;
     if (!szFormat) {
         if (err == 0) {
             lstrcpyA(szBp, "Unknown error code");
@@ -301,10 +303,10 @@ apxLogWrite(
     len = lstrlenA(buffer);
     if (len > 0) {
         /* Remove trailing line separator */
-        if (buffer[len - 1] == '\n') {
-            buffer[len - 1] = '\0';
-            --len;
-        }
+        if (buffer[len - 1] == '\n')
+            buffer[--len] = '\0';
+        if (len > 0 && buffer[len - 1] == '\r')
+            buffer[--len] = '\0';
         if (!IS_INVALID_HANDLE(lf->hFile)) {
             SYSTEMTIME t;
             GetLocalTime(&t);
@@ -327,7 +329,8 @@ apxLogWrite(
                 wsprintfA(sb, "(%10s:%-4d) ", f, dwLine);
                 WriteFile(lf->hFile, sb, lstrlenA(sb), &wr, NULL);
             }
-            WriteFile(lf->hFile, buffer, len, &wr, NULL);
+            if (len)
+                WriteFile(lf->hFile, buffer, len, &wr, NULL);
 
             /* Terminate the line */
             WriteFile(lf->hFile, LINE_SEP, sizeof(LINE_SEP) - 1, &wr, NULL);
@@ -389,6 +392,8 @@ apxDisplayError(
         if(f != szFile)
             f++;
     }
+    else
+        f = "";
     sysbuf[0] = '\0';
     if (err != ERROR_SUCCESS) {
         len = FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM |
@@ -399,15 +404,13 @@ apxDisplayError(
                              sysbuf,
                              SIZ_DESLEN,
                              NULL);
+        sysbuf[len] = '\0';
         if (len > 0) {
-            sysbuf[len] = '\0';
-            if (sysbuf[len - 1] == '\n') {
-                sysbuf[len - 1] = '\0';
-                --len;
-            }
+            if (sysbuf[len - 1] == '\n')
+                sysbuf[--len] = '\0';
+            if (len > 0 && sysbuf[len - 1] == '\r')
+                sysbuf[--len] = '\0';
         }
-        else
-            sysbuf[0] = '\0';
     }
     if (szFormat) {
         va_start(args, szFormat);
@@ -418,7 +421,7 @@ apxDisplayError(
             wsprintfA(sb, "%s (%d)", f, dwLine);
             lstrcatA(sysbuf, sb);
         }
-        lstrlcatA(sysbuf, SIZ_HUGLEN, "\n");
+        lstrlcatA(sysbuf, SIZ_HUGLEN, LINE_SEP);
         lstrlcatA(sysbuf, SIZ_HUGLEN, buffer);
     }
     len = lstrlenA(sysbuf);
@@ -434,7 +437,7 @@ apxDisplayError(
         else {
             fputs(sysbuf, stderr);
             if (!szFormat)
-                fputc('\n', stderr);
+                fputs(LINE_SEP, stderr);
             fflush(stderr);
         }
     }



Mime
View raw message