]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/Debug.h
4 * DEBUG: section 0 Debug Routines
5 * AUTHOR: Harvest Derived
7 * SQUID Web Proxy Cache http://www.squid-cache.org/
8 * ----------------------------------------------------------
10 * Squid is the result of efforts by numerous individuals from
11 * the Internet community; see the CONTRIBUTORS file for full
12 * details. Many organizations have provided support for Squid's
13 * development; see the SPONSORS file for full details. Squid is
14 * Copyrighted (C) 2001 by the Regents of the University of
15 * California; see the COPYRIGHT file for full details. Squid
16 * incorporates software developed and/or copyrighted by other
17 * sources; see the CREDITS file for full details.
19 * This program is free software; you can redistribute it and/or modify
20 * it under the terms of the GNU General Public License as published by
21 * the Free Software Foundation; either version 2 of the License, or
22 * (at your option) any later version.
24 * This program is distributed in the hope that it will be useful,
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27 * GNU General Public License for more details.
29 * You should have received a copy of the GNU General Public License
30 * along with this program; if not, write to the Free Software
31 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
55 #define assert(EX) ((void)0)
56 #elif defined(NODEBUG)
57 #define assert(EX) ((void)0)
59 #define assert(EX) ((EX)?((void)0):xassert( # EX , __FILE__, __LINE__))
61 #define assert(EX) ((EX)?((void)0):xassert("EX", __FILE__, __LINE__))
64 /* context-based debugging, the actual type is subject to change */
67 /* defined debug section limits */
68 #define MAX_DEBUG_SECTIONS 100
70 /* defined names for Debug Levels */
71 #define DBG_CRITICAL 0 /**< critical messages always shown when they occur */
72 #define DBG_IMPORTANT 1 /**< important messages always shown when their section is being checked */
73 /* levels 2-8 are still being discussed amongst the developers */
74 #define DBG_DATA 9 /**< output is a large data dump only necessary for advanced debugging */
80 static char *debugOptions
;
81 static char *cache_log
;
82 static int rotateNumber
;
83 static int Levels
[MAX_DEBUG_SECTIONS
];
85 static int override_X
;
86 static int log_stderr
;
87 static bool log_syslog
;
89 static std::ostream
&getDebugOut();
90 static void finishDebug();
91 static void parseOptions(char const *);
94 // Hack: replaces global ::xassert() to debug debugging assertions
95 static void xassert(const char *msg
, const char *file
, int line
);
97 static std::ostringstream
*CurrentDebug
;
98 static int TheDepth
; // level of nested debugging calls
101 extern FILE *debug_log
;
103 const size_t BuildPrefixInit();
104 const char * SkipBuildPrefix(const char* path
);
107 #define debugs(SECTION, LEVEL, CONTENT) \
109 if ((Debug::level = (LEVEL)) <= Debug::Levels[SECTION]) { \
110 Debug::getDebugOut() << CONTENT; \
111 Debug::finishDebug(); \
113 } while (/*CONSTCOND*/ 0)
116 * HERE is a macro that you can use like this:
118 * debugs(1,2, HERE << "some message");
120 #define HERE SkipBuildPrefix(__FILE__)<<"("<<__LINE__<<") "<<__FUNCTION__<<": "
123 * MYNAME is for use at debug levels 0 and 1 where HERE is too messy.
125 * debugs(1,1, MYNAME << "WARNING: some message");
127 #ifdef __PRETTY_FUNCTION__
128 #define MYNAME __PRETTY_FUNCTION__ << " "
130 #define MYNAME __FUNCTION__ << " "
133 /* some uint8_t do not like streaming control-chars (values 0-31, 127+) */
134 inline std::ostream
& operator <<(std::ostream
&os
, const uint8_t d
)
136 return (os
<< (int)d
);
139 /* Legacy debug style. Still used in some places. needs to die... */
140 #define do_debug(SECTION, LEVEL) ((Debug::level = (LEVEL)) > Debug::Levels[SECTION])
141 #define old_debug(SECTION, LEVEL) \
142 do_debug(SECTION, LEVEL) ? (void) 0 : _db_print
145 #endif /* SQUID_DEBUG_H */