11 #ifndef SQUID_SRC_DEBUG_STREAM_H
12 #define SQUID_SRC_DEBUG_STREAM_H
27 #define assert(EX) ((void)0)
28 #elif defined(NODEBUG)
29 #define assert(EX) ((void)0)
31 #define assert(EX) ((EX)?((void)0):xassert( # EX , __FILE__, __LINE__))
33 #define assert(EX) ((EX)?((void)0):xassert("EX", __FILE__, __LINE__))
37 #define MAX_DEBUG_SECTIONS 100
40 #define DBG_CRITICAL 0
41 #define DBG_IMPORTANT 1
45 #define DBG_PARSE_NOTE(x) (opt_parse_cfg_only?0:(x))
57 Context(
const int aSectionLevel,
const int aLevel);
67 void rewind(
const int aSection,
const int aLevel);
70 std::ostringstream
buf;
117 static std::ostream&
Extra(std::ostream &os) {
return os <<
"\n "; }
185 #define debug_log DebugStream()
196 #define debugs(SECTION, LEVEL, CONTENT) \
198 const int _dbg_level = (LEVEL); \
199 if (Debug::Enabled((SECTION), _dbg_level)) { \
200 std::ostream &_dbo = Debug::Start((SECTION), _dbg_level); \
201 if (_dbg_level > DBG_IMPORTANT) { \
202 _dbo << (SECTION) << ',' << _dbg_level << "| " \
235 #ifdef __PRETTY_FUNCTION__
236 #define MYNAME __PRETTY_FUNCTION__ << " "
238 #define MYNAME __FUNCTION__ << " "
242 inline std::ostream&
operator <<(std::ostream &os,
const uint8_t d)
244 return (os << (
int)d);
meta-information for debugs() or a similar debugging call
int section
the debug section of the debugs() call
Context * upper
previous or parent record in nested debugging calls
int sectionLevel
maximum debugging level allowed during the call
std::ostringstream buf
debugs() output sink
int level
minimum debugging level required by the debugs() call
bool forceAlert
the current debugs() will be a syslog ALERT
void formatStream()
configures default formatting for the debugging stream
void rewind(const int aSection, const int aLevel)
Optimization: avoids new Context creation for every debugs().
Context(const int aSectionLevel, const int aLevel)
static void ResetStderrLevel(int maxLevel)
static bool StderrEnabled()
static void parseOptions(char const *)
static void PrepareToDie()
static void ForgetSaved()
silently erases saved early debugs() messages (if any)
static bool Enabled(const int section, const int level)
whether debugging the given section and the given level produces output
static Context * Current
deepest active context; nil outside debugs()
static void NameThisKid(int kidIdentifier)
static int SectionLevel()
maximum level currently allowed
static void LogMessage(const Context &)
broadcasts debugs() message to the logging channels
static void SettleSyslog()
static int Levels[MAX_DEBUG_SECTIONS]
static void Finish()
logs output buffer created in Start() and closes debugging context
static std::ostream & Extra(std::ostream &os)
prefixes each grouped debugs() line after the first one in the group
static void NameThisHelper(const char *name)
static char * debugOptions
static void UseCacheLog()
static std::ostringstream & Start(const int section, const int level)
opens debugging context and returns output buffer
static void BanCacheLogUse()
static void ConfigureSyslog(const char *facility)
enables logging to syslog (using the specified facility, when not nil)
static void StopCacheLogUse()
static int Level()
minimum level required by the current debugs() call
static void EnsureDefaultStderrLevel(int maxDefault)
static void SettleStderr()
static void LogWaitingForIdle()
Logs messages of Finish()ed debugs() calls that were queued earlier.
static void ForceAlert()
configures the active debugging context to write syslog ALERT
std::ostream & HERE(std::ostream &s)
void ResyncDebugLog(FILE *newDestination)
a hack for low-level file descriptor manipulations in ipcCreate()
std::ostream & ForceAlert(std::ostream &s)
#define MAX_DEBUG_SECTIONS
std::ostream & operator<<(std::ostream &os, const uint8_t d)
void _db_rotate_log(void)