#include <Stream.h>

Collaboration diagram for Debug:

Classes

class  Context
 meta-information for debugs() or a similar debugging call More...
 

Static Public Member Functions

static bool Enabled (const int section, const int level)
 whether debugging the given section and the given level produces output More...
 
static void NameThisHelper (const char *name)
 
static void NameThisKid (int kidIdentifier)
 
static void parseOptions (char const *)
 
static int Level ()
 minimum level required by the current debugs() call More...
 
static int SectionLevel ()
 maximum level currently allowed More...
 
static std::ostringstream & Start (const int section, const int level)
 opens debugging context and returns output buffer More...
 
static void Finish ()
 logs output buffer created in Start() and closes debugging context More...
 
static void ForceAlert ()
 configures the active debugging context to write syslog ALERT More...
 
static std::ostream & Extra (std::ostream &os)
 prefixes each grouped debugs() line after the first one in the group More...
 
static void ForgetSaved ()
 silently erases saved early debugs() messages (if any) More...
 
static void PrepareToDie ()
 
static void LogWaitingForIdle ()
 Logs messages of Finish()ed debugs() calls that were queued earlier. More...
 
static void BanCacheLogUse ()
 
static void UseCacheLog ()
 
static void StopCacheLogUse ()
 
static void EnsureDefaultStderrLevel (int maxDefault)
 
static void ResetStderrLevel (int maxLevel)
 
static void SettleStderr ()
 
static bool StderrEnabled ()
 
static void ConfigureSyslog (const char *facility)
 enables logging to syslog (using the specified facility, when not nil) More...
 
static void SettleSyslog ()
 

Static Public Attributes

static char * debugOptions = NULL
 
static char * cache_log = NULL
 
static int rotateNumber = -1
 
static int Levels [MAX_DEBUG_SECTIONS]
 
static int override_X = 0
 
static bool log_syslog = false
 

Static Private Member Functions

static void LogMessage (const Context &)
 broadcasts debugs() message to the logging channels More...
 

Static Private Attributes

static ContextCurrent = nullptr
 deepest active context; nil outside debugs() More...
 

Detailed Description

Definition at line 49 of file Stream.h.

Member Function Documentation

◆ BanCacheLogUse()

void Debug::BanCacheLogUse ( )
static

Starts using stderr as a cache_log file replacement. Also applies configured debug_options (if any). Call this or UseCacheLog() to stop early message accumulation.

Definition at line 1113 of file debug.cc.

References DebugModule::banCacheLogUse(), debugOptions, Module(), and parseOptions().

Referenced by ConfigureDebugging(), mainHandleCommandLineOption(), NameThisHelper(), and IcmpPinger::Open().

◆ ConfigureSyslog()

void Debug::ConfigureSyslog ( const char *  facility)
static

Definition at line 1078 of file debug.cc.

References fatalf().

Referenced by mainHandleCommandLineOption().

◆ Enabled()

◆ EnsureDefaultStderrLevel()

void Debug::EnsureDefaultStderrLevel ( int  maxDefault)
static

In the absence of ResetStderrLevel() calls, future debugs() with the given (or lower) level will be written to stderr (at least). If called many times, the highest parameter wins. ResetStderrLevel() overwrites this default-setting method, regardless of the calls order.

Definition at line 691 of file debug.cc.

References DefaultStderrLevel.

Referenced by mainHandleCommandLineOption(), and NameThisHelper().

◆ Extra()

◆ Finish()

◆ ForceAlert()

void Debug::ForceAlert ( )
static

Definition at line 1388 of file debug.cc.

References Current, and Debug::Context::forceAlert.

Referenced by ForceAlert().

◆ ForgetSaved()

void Debug::ForgetSaved ( )
static

Definition at line 552 of file debug.cc.

References Module().

Referenced by GoIntoBackground().

◆ Level()

static int Debug::Level ( )
inlinestatic

Definition at line 104 of file Stream.h.

References Current, and Debug::Context::level.

Referenced by debugLogTime().

◆ LogMessage()

void Debug::LogMessage ( const Context context)
staticprivate

◆ LogWaitingForIdle()

void Debug::LogWaitingForIdle ( )
static

◆ NameThisHelper()

void Debug::NameThisHelper ( const char *  name)
static

Use the given name for debugs() messages from this helper process. Side effect: Commits to using helper-appropriate debug levels/channels.

See also
NameThisKid()

Definition at line 382 of file debug.cc.

References assert, BanCacheLogUse(), DBG_DATA, debugOptions, debugs, EnsureDefaultStderrLevel(), LabelThisProcess(), SettleStderr(), SettleSyslog(), and xstrdup.

Referenced by main().

◆ NameThisKid()

void Debug::NameThisKid ( int  kidIdentifier)
static

Use the given ID for debugs() messages from this SMP kid process.

See also
NameThisHelper()

Definition at line 405 of file debug.cc.

References LabelThisProcess(), and ProcessLabel.

Referenced by ConfigureCurrentKid().

◆ parseOptions()

void Debug::parseOptions ( char const *  options)
static

◆ PrepareToDie()

void Debug::PrepareToDie ( )
static

Reacts to ongoing program termination (e.g., flushes buffered messages). Call this before logging the termination reason to maximize the chances of that valuable debugs() getting through to the admin.

Definition at line 561 of file debug.cc.

References Module(), and DebugModule::prepareToDie().

Referenced by DebugModule::DebugModule(), death(), fatal_dump(), OnTerminate(), and xassert().

◆ ResetStderrLevel()

void Debug::ResetStderrLevel ( int  maxLevel)
static

Future debugs() messages with the given (or lower) level will be written to stderr (at least). If called many times, the last call wins.

Definition at line 699 of file debug.cc.

References ExplicitStderrLevel.

Referenced by mainHandleCommandLineOption().

◆ SectionLevel()

static int Debug::SectionLevel ( )
inlinestatic

Definition at line 106 of file Stream.h.

References Current, and Debug::Context::sectionLevel.

Referenced by Raw::print().

◆ SettleStderr()

void Debug::SettleStderr ( )
static

Finalizes stderr configuration when no (more) ResetStderrLevel() and EnsureDefaultStderrLevel() calls are expected.

Definition at line 705 of file debug.cc.

References DBG_CRITICAL, DBG_DATA, debugs, ExplicitStderrLevel, Module(), override_X, DebugModule::stderrChannel, and DebugChannel::stopEarlyMessageCollection().

Referenced by NameThisHelper(), and SquidMain().

◆ SettleSyslog()

void Debug::SettleSyslog ( )
static

Finalizes syslog configuration when no (more) ConfigureSyslog() calls are expected.

Definition at line 1140 of file debug.cc.

References APP_SHORTNAME, log_syslog, SyslogChannel::markOpened(), Module(), DebugChannel::stopEarlyMessageCollection(), and DebugModule::syslogChannel.

Referenced by Module(), NameThisHelper(), and SquidMain().

◆ Start()

std::ostringstream & Debug::Start ( const int  section,
const int  level 
)
static

◆ StderrEnabled()

bool Debug::StderrEnabled ( )
static

Whether at least some debugs() messages may be written to stderr. The answer may be affected by BanCacheLogUse() and SettleStderr().

Definition at line 725 of file debug.cc.

References DBG_CRITICAL, StderrChannel::enabled(), Module(), and DebugModule::stderrChannel.

Referenced by watch_child().

◆ StopCacheLogUse()

void Debug::StopCacheLogUse ( )
static

Closes and stops using cache_log (if it was open). Starts using stderr as a cache_log file replacement.

Definition at line 1127 of file debug.cc.

References DebugModule::banCacheLogUse(), DebugModule::cacheLogChannel, DebugFile::clear(), DebugFile::file(), Module(), DebugChannel::stopEarlyMessageCollection(), and TheLog.

Referenced by RemoveInstance().

◆ UseCacheLog()

void Debug::UseCacheLog ( )
static

Opens and starts using the configured cache_log file. Also applies configured debug_options (if any). Call this or BanCacheLogUse() to stop early message accumulation.

Definition at line 1120 of file debug.cc.

References cache_log, debugOpenLog(), debugOptions, and parseOptions().

Referenced by ConfigureDebugging(), and mainReconfigureFinish().

Member Data Documentation

◆ cache_log

char * Debug::cache_log = NULL
static

Definition at line 85 of file Stream.h.

Referenced by _db_rotate_log(), DebugFile::reset(), and UseCacheLog().

◆ Current

Debug::Context * Debug::Current = nullptr
staticprivate

Definition at line 178 of file Stream.h.

Referenced by Finish(), ForceAlert(), Level(), Debug::Context::rewind(), SectionLevel(), and Start().

◆ debugOptions

char * Debug::debugOptions = NULL
static

◆ Levels

◆ log_syslog

bool Debug::log_syslog = false
static

Definition at line 89 of file Stream.h.

Referenced by SettleSyslog(), and SyslogChannel::shouldWrite().

◆ override_X

int Debug::override_X = 0
static

Definition at line 88 of file Stream.h.

Referenced by mainHandleCommandLineOption(), parseOptions(), and SettleStderr().

◆ rotateNumber

int Debug::rotateNumber = -1
static

Definition at line 86 of file Stream.h.

Referenced by _db_rotate_log(), configDoConfigure(), and debugArg().


The documentation for this class was generated from the following files:

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors