From: robertc <> Date: Fri, 17 Jan 2003 12:14:29 +0000 (+0000) Subject: give Debug a class X-Git-Tag: SQUID_3_0_PRE1~458 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c772f001816155f3acb072da1b5ee25c5a542692;p=thirdparty%2Fsquid.git give Debug a class --- diff --git a/src/Debug.h b/src/Debug.h new file mode 100644 index 0000000000..58f385c3ee --- /dev/null +++ b/src/Debug.h @@ -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 */ diff --git a/src/HttpHeaderTools.cc b/src/HttpHeaderTools.cc index 4ca17914f0..0ce931780f 100644 --- a/src/HttpHeaderTools.cc +++ b/src/HttpHeaderTools.cc @@ -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; diff --git a/src/Makefile.am b/src/Makefile.am index 3a56044fdd..12ce03aa54 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -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 \ diff --git a/src/debug.cc b/src/debug.cc index 3aa5a7bcaa..e14665fa38 100644 --- a/src/debug.cc +++ b/src/debug.cc @@ -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 @@ -34,6 +34,10 @@ */ #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); diff --git a/src/defines.h b/src/defines.h index c7ed12613b..f07909c1bb 100644 --- a/src/defines.h +++ b/src/defines.h @@ -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; } diff --git a/src/dns_internal.cc b/src/dns_internal.cc index feeb7a0b14..e642b5e8b8 100644 --- a/src/dns_internal.cc +++ b/src/dns_internal.cc @@ -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", diff --git a/src/globals.h b/src/globals.h index 89b0d08dc9..9b0467afc0 100644 --- a/src/globals.h +++ b/src/globals.h @@ -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" */