File Reference
#include "squid.h"
#include "base/Optional.h"
#include "base/TextException.h"
#include "debug/Stream.h"
#include "fd.h"
#include "ipc/Kids.h"
#include "time/gadgets.h"
#include "util.h"
#include <algorithm>
#include <deque>
#include <functional>
#include <memory>
Include dependency graph for

Go to the source code of this file.


class  DebugFile
 a named FILE with very-early/late usage safety mechanisms More...
class  DebugMessageHeader
 meta-information of a Finish()ed debugs() message More...
class  CompiledDebugMessage
 a fully processed debugs(), ready to be logged More...
class  DebugChannel
 a receiver of debugs() messages (e.g., stderr or cache.log) More...
class  DebugChannel::Logger
 output iterator for writing CompiledDebugMessages to a given channel More...
class  CacheLogChannel
 DebugChannel managing messages destined for the configured cache_log file. More...
class  StderrChannel
 DebugChannel managing messages destined for "standard error stream" (stderr) More...
class  SyslogChannel
 syslog DebugChannel More...
class  DebugModule
class  LoggingSectionGuard


using DebugRecordCount = uint64_t
 a counter related to the number of debugs() calls More...
using CompiledDebugMessageBody = std::string
 The processed "content" (i.e. the last parameter) part of a debugs() call. More...
using CompiledDebugMessages = std::deque< CompiledDebugMessage >
 debugs() messages captured in LogMessage() call order More...


static const char * debugLogTime (time_t t)
static void ResetSections (const int level)
 used for the side effect: fills Debug::Levels with the given level More...
FILE * DebugStream ()
static void LabelThisProcess (const char *const name, const Optional< int > id=Optional< int >())
 optimization: formats ProcessLabel once for frequent debugs() reuse More...
static DebugModuleModule ()
 safe access to the debugging module More...
void ResyncDebugLog (FILE *newFile)
 a hack for low-level file descriptor manipulations in ipcCreate() More...
static void debugArg (const char *arg)
static void debugOpenLog (const char *logfile)
void _db_rotate_log (void)
void xassert (const char *msg, const char *file, int line)
std::ostream & ForceAlert (std::ostream &s)


static DebugModuleModule_ = nullptr
 Debugging module singleton. More...
static Optional< intExplicitStderrLevel
static int DefaultStderrLevel = -1
static constexpr int EarlyMessagesLevel = DBG_IMPORTANT
 early debugs() with higher level are not buffered and, hence, may be lost More...
static std::string ProcessLabel
 pre-formatted name of the current process for debugs() messages (or empty) More...
static bool DidResetSections = false
static Debug::ContextWaitingForIdle = nullptr
static DebugFile TheLog
static auto Asserting_ = false

Typedef Documentation

◆ CompiledDebugMessageBody

using CompiledDebugMessageBody = std::string

Definition at line 124 of file

◆ CompiledDebugMessages

Definition at line 143 of file

◆ DebugRecordCount

using DebugRecordCount = uint64_t

Definition at line 33 of file

Function Documentation

◆ _db_rotate_log()

void _db_rotate_log ( void  )

Definition at line 1155 of file

Referenced by mainRotate().

◆ debugArg()

static void debugArg ( const char *  arg)

Definition at line 821 of file

References assert, Debug::Levels, MAX_DEBUG_SECTIONS, ResetSections(), and Debug::rotateNumber.

Referenced by Debug::parseOptions().

◆ debugLogTime()

static const char * debugLogTime ( time_t  t)

Definition at line 1222 of file

References assert, current_time, Debug::Level(), and sz.

Referenced by DebugChannel::writeToStream().

◆ debugOpenLog()

static void debugOpenLog ( const char *  logfile)

◆ DebugStream()

FILE* DebugStream ( )

cache.log FILE or, as the last resort, stderr stream; may be nil during static initialization and destruction!

Definition at line 353 of file

References DebugFile::file(), and TheLog.

◆ ForceAlert()

std::ostream& ForceAlert ( std::ostream &  s)

Does not change the stream being manipulated. Exists for its side effect: In a debugs() context, forces the message to become a syslog ALERT. Outside of debugs() context, has no effect and should not be used.

Definition at line 1396 of file

Referenced by death(), and fatal_common().

◆ LabelThisProcess()

static void LabelThisProcess ( const char *const  name,
const Optional< int id = Optional<int>() 

Definition at line 368 of file

References assert, and ProcessLabel.

Referenced by Debug::NameThisHelper(), and Debug::NameThisKid().

◆ Module()

◆ ResetSections()

static void ResetSections ( const int  level = DBG_IMPORTANT)

Definition at line 359 of file

References DidResetSections, and Debug::Levels.

Referenced by DebugModule::DebugModule(), debugArg(), and Debug::parseOptions().

◆ ResyncDebugLog()

void ResyncDebugLog ( FILE *  newFile)

Definition at line 513 of file

References DebugFile::file_, and TheLog.

Referenced by ipcCreate().

◆ xassert()

void xassert ( const char *  msg,
const char *  file,
int  line 

Definition at line 1254 of file

References Asserting_, DBG_CRITICAL, debugs, and Debug::PrepareToDie().

Variable Documentation

◆ Asserting_

auto Asserting_ = false

Whether there are any xassert() calls in the call stack. Treat as private to xassert(): It is moved out only to simplify the asserting code path.

Definition at line 1251 of file

Referenced by xassert().

◆ DefaultStderrLevel

int DefaultStderrLevel = -1

ExplicitStderrLevel preference or default: Just like with ExplicitStderrLevel, debugs() messages with this (or lower) level will be written to stderr (and possibly other channels), but this setting is ignored when ExplicitStderrLevel is set. This setting is also ignored after major problems that prevent logging of important debugs() messages (e.g., failing to open cache_log or assertions).

Definition at line 51 of file

Referenced by StderrChannel::enabled(), and Debug::EnsureDefaultStderrLevel().

◆ DidResetSections

bool DidResetSections = false

Whether ResetSections() has been called already. We need to keep track of this state because external code may trigger ResetSections() before the DebugModule constructor has a chance to ResetSections() to their defaults. TODO: Find a way to static-initialize Debug::Levels instead.

Definition at line 78 of file

Referenced by DebugModule::DebugModule(), and ResetSections().

◆ EarlyMessagesLevel

constexpr int EarlyMessagesLevel = DBG_IMPORTANT

Definition at line 54 of file

Referenced by DebugChannel::saveMessage().

◆ ExplicitStderrLevel

Optional<int> ExplicitStderrLevel

Explicitly configured maximum level for debugs() messages written to stderr. debugs() messages with this (or lower) level will be written to stderr (and possibly other channels).

Definition at line 43 of file

Referenced by StderrChannel::enabled(), Debug::ResetStderrLevel(), and Debug::SettleStderr().

◆ Module_

DebugModule* Module_ = nullptr

Definition at line 38 of file

Referenced by Module().

◆ ProcessLabel

std::string ProcessLabel

Definition at line 57 of file

Referenced by LabelThisProcess(), Debug::NameThisKid(), and DebugChannel::writeToStream().

◆ TheLog

DebugFile TheLog

cache_log file safe during static initialization, even if it has not been constructed yet safe during program termination, even if it has been destructed already

Definition at line 350 of file

Referenced by _db_rotate_log(), DebugModule::banCacheLogUse(), debugOpenLog(), DebugStream(), Debug::LogMessage(), DebugModule::prepareToDie(), ResyncDebugLog(), CacheLogChannel::shouldWrite(), Debug::StopCacheLogUse(), DebugModule::useCacheLog(), and CacheLogChannel::write().

◆ WaitingForIdle

Debug::Context* WaitingForIdle = nullptr

debugs() messages postponed due to LoggingSectionGuard::Busy(). This is the head of the invasive Context::upper FIFO list of such messages.

Definition at line 345 of file

Referenced by Debug::Finish(), and Debug::LogWaitingForIdle().






Web Site Translations