/*
* $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;
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
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
va_list args2;
va_list args3;
-#ifdef _SQUID_MSWIN_
+#if _SQUID_MSWIN_
/* Multiple WIN32 threads may call this simultaneously */
if (!dbg_mutex) {
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);
_db_print_syslog(format, args3);
#endif
-#ifdef _SQUID_MSWIN_
+#if _SQUID_MSWIN_
LeaveCriticalSection(dbg_mutex);
#endif
debug_log = stderr;
}
-#ifdef _SQUID_WIN32_
+#if _SQUID_WINDOWS_
setmode(fileno(debug_log), O_TEXT);
-
#endif
}
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
* 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
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)
{
std::ostringstream (*Debug::CurrentDebug)(NULL);
-const size_t
+size_t
BuildPrefixInit()
{
// XXX: This must be kept in sync with the actual debug.cc location