]> git.ipfire.org Git - thirdparty/squid.git/blobdiff - src/debug.cc
Renamed squid.h to squid-old.h and config.h to squid.h
[thirdparty/squid.git] / src / debug.cc
index 8f29b627376258d93243fdabd3c973567745c934..a2eb7d2c4f3794d9102da41f1a790dbdae193a5f 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * $Id$
  *
- * DEBUG: section 0     Debug Routines
+ * DEBUG: section 00    Debug Routines
  * AUTHOR: Harvest Derived
  *
  * SQUID Web Proxy Cache          http://www.squid-cache.org/
  *
  */
 
-#include "config.h"
+#include "squid.h"
 #include "Debug.h"
 #include "SquidTime.h"
 #include "util.h"
+#include "ipc/Kids.h"
 
 /* for shutting_down flag in xassert() */
 #include "globals.h"
 
-/* cope with no squid.h */
-#ifndef MAXPATHLEN
-#define MAXPATHLEN 256
-#endif
-
 char *Debug::debugOptions = NULL;
 int Debug::override_X = 0;
 int Debug::log_stderr = -1;
@@ -57,6 +53,7 @@ FILE *debug_log = NULL;
 static char *debug_log_file = NULL;
 static int Ctx_Lock = 0;
 static const char *debugLogTime(void);
+static const char *debugLogKid(void);
 static void ctx_print(void);
 #if HAVE_SYSLOG
 #ifdef LOG_LOCAL4
@@ -67,7 +64,7 @@ static void _db_print_syslog(const char *format, va_list args);
 static void _db_print_stderr(const char *format, va_list args);
 static void _db_print_file(const char *format, va_list args);
 
-#ifdef _SQUID_MSWIN_
+#if _SQUID_MSWIN_
 SQUIDCEXTERN LPCRITICAL_SECTION dbg_mutex;
 typedef BOOL (WINAPI * PFInitializeCriticalSectionAndSpinCount) (LPCRITICAL_SECTION, DWORD);
 #endif
@@ -81,7 +78,7 @@ _db_print(const char *format,...)
     va_list args2;
     va_list args3;
 
-#ifdef _SQUID_MSWIN_
+#if _SQUID_MSWIN_
     /* Multiple WIN32 threads may call this simultaneously */
 
     if (!dbg_mutex) {
@@ -122,8 +119,9 @@ _db_print(const char *format,...)
     va_start(args2, format);
     va_start(args3, format);
 
-    snprintf(f, BUFSIZ, "%s| %s",
+    snprintf(f, BUFSIZ, "%s%s| %s",
              debugLogTime(),
+             debugLogKid(),
              format);
 
     _db_print_file(f, args1);
@@ -133,7 +131,7 @@ _db_print(const char *format,...)
     _db_print_syslog(format, args3);
 #endif
 
-#ifdef _SQUID_MSWIN_
+#if _SQUID_MSWIN_
     LeaveCriticalSection(dbg_mutex);
 #endif
 
@@ -257,9 +255,8 @@ debugOpenLog(const char *logfile)
         debug_log = stderr;
     }
 
-#ifdef _SQUID_WIN32_
+#if _SQUID_WINDOWS_
     setmode(fileno(debug_log), O_TEXT);
-
 #endif
 }
 
@@ -490,7 +487,7 @@ _db_rotate_log(void)
         i--;
         snprintf(from, MAXPATHLEN, "%s.%d", debug_log_file, i - 1);
         snprintf(to, MAXPATHLEN, "%s.%d", debug_log_file, i);
-#ifdef _SQUID_MSWIN_
+#if _SQUID_MSWIN_
         remove
         (to);
 #endif
@@ -501,14 +498,14 @@ _db_rotate_log(void)
      * You can't rename open files on Microsoft "operating systems"
      * so we close before renaming.
      */
-#ifdef _SQUID_MSWIN_
+#if _SQUID_MSWIN_
     if (debug_log != stderr)
         fclose(debug_log);
 #endif
     /* Rotate the current log to .0 */
     if (Debug::rotateNumber > 0) {
         snprintf(to, MAXPATHLEN, "%s.%d", debug_log_file, 0);
-#ifdef _SQUID_MSWIN_
+#if _SQUID_MSWIN_
         remove
         (to);
 #endif
@@ -548,6 +545,19 @@ debugLogTime(void)
     return buf;
 }
 
+static const char *
+debugLogKid(void)
+{
+    if (KidIdentifier != 0) {
+        static char buf[16];
+        if (!*buf) // optimization: fill only once after KidIdentifier is set
+            snprintf(buf, sizeof(buf), " kid%d", KidIdentifier);
+        return buf;
+    }
+
+    return "";
+}
+
 void
 xassert(const char *msg, const char *file, int line)
 {
@@ -772,7 +782,7 @@ Debug::xassert(const char *msg, const char *file, int line)
 
 std::ostringstream (*Debug::CurrentDebug)(NULL);
 
-const size_t
+size_t
 BuildPrefixInit()
 {
     // XXX: This must be kept in sync with the actual debug.cc location