]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
give Debug a class
authorrobertc <>
Fri, 17 Jan 2003 12:14:29 +0000 (12:14 +0000)
committerrobertc <>
Fri, 17 Jan 2003 12:14:29 +0000 (12:14 +0000)
src/Debug.h [new file with mode: 0644]
src/HttpHeaderTools.cc
src/Makefile.am
src/debug.cc
src/defines.h
src/dns_internal.cc
src/globals.h

diff --git a/src/Debug.h b/src/Debug.h
new file mode 100644 (file)
index 0000000..58f385c
--- /dev/null
@@ -0,0 +1,46 @@
+
+/*
+ * $Id: Debug.h,v 1.1 2003/01/17 05:14:29 robertc Exp $
+ *
+ * DEBUG: section 0     Debug Routines
+ * AUTHOR: Harvest Derived
+ *
+ * SQUID Web Proxy Cache          http://www.squid-cache.org/
+ * ----------------------------------------------------------
+ *
+ *  Squid is the result of efforts by numerous individuals from
+ *  the Internet community; see the CONTRIBUTORS file for full
+ *  details.   Many organizations have provided support for Squid's
+ *  development; see the SPONSORS file for full details.  Squid is
+ *  Copyrighted (C) 2001 by the Regents of the University of
+ *  California; see the COPYRIGHT file for full details.  Squid
+ *  incorporates software developed and/or copyrighted by other
+ *  sources; see the CREDITS file for full details.
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *  
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *  
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
+ *
+ */
+
+#ifndef SQUID_DEBUG
+#define SQUID_DEBUG
+
+class Debug 
+{
+public:
+  static int Levels[MAX_DEBUG_SECTIONS];
+  static int level;
+};
+
+#endif /* SQUID_DEBUG */
index 4ca17914f031d4c9cbbe38baafdb0890ce5f44ec..0ce931780f267e4654fd1533d03d799f37786bbd 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: HttpHeaderTools.cc,v 1.33 2002/10/13 20:34:56 robertc Exp $
+ * $Id: HttpHeaderTools.cc,v 1.34 2003/01/17 05:14:29 robertc Exp $
  *
  * DEBUG: section 66    HTTP Header Tools
  * AUTHOR: Alex Rousskov
@@ -346,9 +346,9 @@ httpHeaderTestParser(const char *hstr)
     else if (strstr(hstr, "\n\n"))
        hstr_len -= 1;
     httpHeaderInit(&hdr, hoReply);
-    /* debugLevels[55] = 8; */
+    /* Debug::Levels[55] = 8; */
     parse_success = httpHeaderParse(&hdr, hstr, hstr + hstr_len);
-    /* debugLevels[55] = 2; */
+    /* Debug::Levels[55] = 2; */
     if (!parse_success) {
        debug(66, 2) ("TEST (%d): failed to parsed a header: {\n%s}\n", bug_count, hstr);
        return;
index 3a56044fdd8d1b904f1a1678dd20505009e671ea..12ce03aa54ca886e6ee5aad64ab10935e9b60d76 100644 (file)
@@ -1,7 +1,7 @@
 #
 #  Makefile for the Squid Object Cache server
 #
-#  $Id: Makefile.am,v 1.45 2002/12/27 10:26:33 robertc Exp $
+#  $Id: Makefile.am,v 1.46 2003/01/17 05:17:07 robertc Exp $
 #
 #  Uncomment and customize the following to suit your needs:
 #
@@ -141,6 +141,7 @@ squid_SOURCES = \
        comm_poll.cc \
        comm_kqueue.cc \
        debug.cc \
+       Debug.h \
        defines.h \
        $(DELAY_POOL_SOURCE) \
        disk.cc \
index 3aa5a7bcaa1a36b9845403caec88614eb85bd453..e14665fa38908e0246013c18eaafa3aea3716d1f 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: debug.cc,v 1.85 2002/09/01 15:16:35 hno Exp $
+ * $Id: debug.cc,v 1.86 2003/01/17 05:14:29 robertc Exp $
  *
  * DEBUG: section 0     Debug Routines
  * AUTHOR: Harvest Derived
  */
 
 #include "squid.h"
+#include "Debug.h"
+
+int Debug::Levels[MAX_DEBUG_SECTIONS];
+int Debug::level;
 
 static char *debug_log_file = NULL;
 static int Ctx_Lock = 0;
@@ -105,7 +109,7 @@ _db_print_file(const char *format, va_list args)
 static void
 _db_print_stderr(const char *format, va_list args)
 {
-    if (opt_debug_stderr < _db_level)
+    if (opt_debug_stderr < Debug::level)
        return;
     if (debug_log == stderr)
        return;
@@ -118,14 +122,14 @@ _db_print_syslog(const char *format, va_list args)
 {
     LOCAL_ARRAY(char, tmpbuf, BUFSIZ);
     /* level 0,1 go to syslog */
-    if (_db_level > 1)
+    if (Debug::level > 1)
        return;
     if (0 == opt_syslog_enable)
        return;
     tmpbuf[0] = '\0';
     vsnprintf(tmpbuf, BUFSIZ, format, args);
     tmpbuf[BUFSIZ - 1] = '\0';
-    syslog(_db_level == 0 ? LOG_WARNING : LOG_NOTICE, "%s", tmpbuf);
+    syslog(Debug::level == 0 ? LOG_WARNING : LOG_NOTICE, "%s", tmpbuf);
 }
 #endif /* HAVE_SYSLOG */
 
@@ -150,11 +154,11 @@ debugArg(const char *arg)
     if (l > 10)
        l = 10;
     if (s >= 0) {
-       debugLevels[s] = l;
+       Debug::Levels[s] = l;
        return;
     }
     for (i = 0; i < MAX_DEBUG_SECTIONS; i++)
-       debugLevels[i] = l;
+       Debug::Levels[i] = l;
 }
 
 static void
@@ -190,7 +194,7 @@ _db_init(const char *logfile, const char *options)
     char *s = NULL;
 
     for (i = 0; i < MAX_DEBUG_SECTIONS; i++)
-       debugLevels[i] = -1;
+       Debug::Levels[i] = -1;
 
     if (options) {
        p = xstrdup(options);
index c7ed12613b8fc354477beecd9d021ba42d98071f..f07909c1bb2f4215665aa59b6367527cce5b970d 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: defines.h,v 1.110 2002/12/13 03:43:37 robertc Exp $
+ * $Id: defines.h,v 1.111 2003/01/17 05:14:29 robertc Exp $
  *
  *
  * SQUID Web Proxy Cache          http://www.squid-cache.org/
@@ -65,8 +65,9 @@
 #define COMM_NOCLOEXEC         0x02
 #define COMM_REUSEADDR         0x04
 
+#include "Debug.h"
 #define debug(SECTION, LEVEL) \
-        ((_db_level = (LEVEL)) > debugLevels[SECTION]) ? (void) 0 : _db_print
+        ((Debug::level = (LEVEL)) > Debug::Levels[SECTION]) ? (void) 0 : _db_print
 
 #define safe_free(x)   if (x) { xxfree(x); x = NULL; }
 
index feeb7a0b14ba9e2783596b40e8069c44f03d6b23..e642b5e8b8465c1d9dc72e7c9f7772a55d676fce 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: dns_internal.cc,v 1.50 2002/10/21 06:43:07 adrian Exp $
+ * $Id: dns_internal.cc,v 1.51 2003/01/17 05:14:29 robertc Exp $
  *
  * DEBUG: section 78    DNS lookups; interacts with lib/rfc1035.c
  * AUTHOR: Duane Wessels
@@ -634,7 +634,7 @@ idnsInit(void)
        if (DnsSocket < 0)
            fatal("Could not create a DNS socket");
        /* Ouch... we can't call functions using debug from a debug
-        * statement. Doing so messes up the internal _db_level
+        * statement. Doing so messes up the internal Debug::level
         */
        port = comm_local_port(DnsSocket);
        debug(78, 1) ("DNS Socket created at %s, port %d, FD %d\n",
index 89b0d08dc98e65692bd142d99a31dbbea523d27c..9b0467afc0a3d5e0fe8180e11940259c43a19f98 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: globals.h,v 1.115 2002/12/06 23:19:15 hno Exp $
+ * $Id: globals.h,v 1.116 2003/01/17 05:14:29 robertc Exp $
  *
  *
  * SQUID Web Proxy Cache          http://www.squid-cache.org/
@@ -74,7 +74,6 @@ extern int NHttpSockets;      /* 0 */
 extern int RESERVED_FD;
 extern int Squid_MaxFD;                /* SQUID_MAXFD */
 extern int config_lineno;      /* 0 */
-extern int debugLevels[MAX_DEBUG_SECTIONS];
 extern int do_mallinfo;                /* 0 */
 extern int opt_reuseaddr;      /* 1 */
 extern int icmp_sock;          /* -1 */
@@ -133,7 +132,6 @@ extern dlink_list ClientActiveRequests;
 extern const String StringNull;        /* { 0, 0, NULL } */
 extern const MemBuf MemBufNull;        /* MemBufNULL */
 extern int hot_obj_count;      /* 0 */
-extern int _db_level;
 extern const int CacheDigestHashFuncCount;     /* 4 */
 extern CacheDigest *store_digest;      /* NULL */
 extern const char *StoreDigestFileName;                /* "store_digest" */