#include <Stream.h>

Collaboration diagram for Debug:


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 &)
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 = nullptr
static char * cache_log = nullptr
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 FormatStream (std::ostream &)
 configures default formatting for the debugging stream More...
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 46 of file Stream.h.

Member Function Documentation

◆ BanCacheLogUse()

void Debug::BanCacheLogUse ( )

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 1115 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)

Definition at line 1080 of file debug.cc.

References fatalf().

Referenced by mainHandleCommandLineOption().

◆ Enabled()

◆ EnsureDefaultStderrLevel()

void Debug::EnsureDefaultStderrLevel ( int  maxDefault)

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 692 of file debug.cc.

References DefaultStderrLevel.

Referenced by mainHandleCommandLineOption(), and NameThisHelper().

◆ Extra()

std::ostream & Debug::Extra ( std::ostream &  os)

Prefixes each grouped debugs() line after the first one in the group. Resets debugging stream format to the initial/default one.

Definition at line 1313 of file debug.cc.

References FormatStream().

Referenced by RegexPattern::RegexPattern(), Store::SwapMetaUnpacker::SwapMetaUnpacker(), Comm::TcpAcceptor::acceptOne(), Helper::Reply::CheckReceivedKey(), Store::CheckSwapMetaUrl(), clientHttpConnectionsOpen(), clientListenerConnectionOpened(), CurrentExceptionExtra(), debugOpenLog(), AccessLogEntry::detailCodeContext(), AnyP::PortCfg::detailCodeContext(), Comm::Connection::detailCodeContext(), htcpSpecifier::detailCodeContext(), MemStore::get(), Helper::Client::handleFewerServers(), Security::PeerConnector::handleNegotiationResult(), Ssl::CertValidationHelper::Init(), Security::IssuedBy(), ConnStateData::lifetimeTimeout(), Security::KeyData::loadCertificates(), neighborIgnoreNonPeer(), neighbors_init(), operator<<(), ACLRegexData::parse(), store_client::parseHttpHeadersFromDisk(), FormattedLog::parseOptions(), Ssl::CertValidationMsg::parseResponse(), HttpReply::parseTerminatedPrefix(), TextException::print(), processNewRequest(), Rock::Rebuild::progressDescription(), Ssl::readCertAndPrivateKeyFromMemory(), Ipc::Port::receiveOrIgnore(), Ipc::QuestionerId::rejectAnswerIfStale(), Ssl::ReportAndForgetErrors(), Acl::SetKey(), setTraceability(), storeCleanup(), storeRebuildComplete(), TestRandomUuid::testInvalidIds(), CacheManagerInternals::testInvalidUrl(), and CacheManagerInternals::testValidUrl().

◆ Finish()

◆ ForceAlert()

void Debug::ForceAlert ( )

Definition at line 1400 of file debug.cc.

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

Referenced by ForceAlert().

◆ ForgetSaved()

void Debug::ForgetSaved ( )

Definition at line 553 of file debug.cc.

References Module().

Referenced by GoIntoBackground().

◆ FormatStream()

void Debug::FormatStream ( std::ostream &  buf)

Definition at line 1302 of file debug.cc.

Referenced by Debug::Context::Context(), Extra(), and Debug::Context::rewind().

◆ Level()

static int Debug::Level ( )

Definition at line 100 of file Stream.h.

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

Referenced by debugLogTime().

◆ LogMessage()

void Debug::LogMessage ( const Context context)

◆ LogWaitingForIdle()

void Debug::LogWaitingForIdle ( )

◆ NameThisHelper()

void Debug::NameThisHelper ( const char *  name)

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

See also

Definition at line 383 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)

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

See also

Definition at line 406 of file debug.cc.

References LabelThisProcess(), and ProcessLabel.

Referenced by ConfigureCurrentKid().

◆ parseOptions()

void Debug::parseOptions ( char const *  options)

◆ PrepareToDie()

void Debug::PrepareToDie ( )

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 562 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)

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 700 of file debug.cc.

References ExplicitStderrLevel.

Referenced by mainHandleCommandLineOption().

◆ SectionLevel()

static int Debug::SectionLevel ( )

Definition at line 102 of file Stream.h.

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

Referenced by Raw::print().

◆ SettleStderr()

void Debug::SettleStderr ( )

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

Definition at line 706 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 ( )

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

Definition at line 1142 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 

◆ StderrEnabled()

bool Debug::StderrEnabled ( )

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

Definition at line 726 of file debug.cc.

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

Referenced by watch_child().

◆ StopCacheLogUse()

void Debug::StopCacheLogUse ( )

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

Definition at line 1129 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 ( )

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 1122 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 = nullptr

Definition at line 81 of file Stream.h.

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

◆ Current

Debug::Context * Debug::Current = nullptr

Definition at line 176 of file Stream.h.

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

◆ debugOptions

char * Debug::debugOptions = nullptr

◆ Levels

◆ log_syslog

bool Debug::log_syslog = false

Definition at line 85 of file Stream.h.

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

◆ override_X

int Debug::override_X = 0

Definition at line 84 of file Stream.h.

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

◆ rotateNumber

int Debug::rotateNumber = -1

Definition at line 82 of file Stream.h.

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

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






Web Site Translations