#include "squid.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 <optional>

Go to the source code of this file.
Classes | |
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 |
Typedefs | |
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... | |
Functions | |
static const char * | debugLogTime (const timeval &) |
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 std::optional< int > id=std::optional< int >()) |
optimization: formats ProcessLabel once for frequent debugs() reuse More... | |
static DebugModule & | Module () |
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) |
Variables | |
static DebugModule * | Module_ = nullptr |
Debugging module singleton. More... | |
static std::optional< int > | ExplicitStderrLevel |
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::Context * | WaitingForIdle = nullptr |
static DebugFile | TheLog |
static auto | Asserting_ = false |
Typedef Documentation
◆ CompiledDebugMessageBody
using CompiledDebugMessageBody = std::string |
◆ CompiledDebugMessages
using CompiledDebugMessages = std::deque<CompiledDebugMessage> |
◆ DebugRecordCount
using DebugRecordCount = uint64_t |
Function Documentation
◆ _db_rotate_log()
void _db_rotate_log | ( | void | ) |
Definition at line 1156 of file debug.cc.
References Debug::cache_log, DebugFile::clear(), DBG_IMPORTANT, debugOpenLog(), debugs, MAXPATHLEN, DebugFile::name, Debug::rotateNumber, sb, TheLog, and xstrerr().
Referenced by mainRotate().
◆ debugArg()
|
static |
Definition at line 822 of file debug.cc.
References assert, Debug::Levels, MAX_DEBUG_SECTIONS, ResetSections(), and Debug::rotateNumber.
Referenced by Debug::parseOptions().
◆ debugLogTime()
|
static |
Definition at line 1223 of file debug.cc.
References assert, and Debug::Level().
Referenced by DebugChannel::writeToStream().
◆ debugOpenLog()
|
static |
Definition at line 860 of file debug.cc.
References assert, DebugModule::banCacheLogUse(), DebugFile::clear(), DBG_CRITICAL, debugs, Debug::Extra(), log(), logfile, Module(), O_TEXT, DebugFile::reset(), TheLog, DebugModule::useCacheLog(), and xstrerr().
Referenced by _db_rotate_log(), and Debug::UseCacheLog().
◆ 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 debug.cc.
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 1397 of file debug.cc.
References Debug::ForceAlert().
Referenced by death(), and fatal_common().
◆ LabelThisProcess()
|
static |
Definition at line 368 of file debug.cc.
References assert, and ProcessLabel.
Referenced by Debug::NameThisHelper(), and Debug::NameThisKid().
◆ Module()
|
static |
Definition at line 499 of file debug.cc.
References Module_, and Debug::SettleSyslog().
Referenced by Debug::BanCacheLogUse(), debugOpenLog(), Debug::ForgetSaved(), Debug::LogMessage(), Debug::PrepareToDie(), Debug::SettleStderr(), Debug::SettleSyslog(), Debug::StderrEnabled(), and Debug::StopCacheLogUse().
◆ ResetSections()
|
static |
Definition at line 359 of file debug.cc.
References DidResetSections, and Debug::Levels.
Referenced by DebugModule::DebugModule(), debugArg(), and Debug::parseOptions().
◆ ResyncDebugLog()
void ResyncDebugLog | ( | FILE * | newFile | ) |
Definition at line 513 of file debug.cc.
Referenced by ipcCreate().
◆ xassert()
void xassert | ( | const char * | msg, |
const char * | file, | ||
int | line | ||
) |
Definition at line 1255 of file debug.cc.
References Asserting_, DBG_CRITICAL, debugs, and Debug::PrepareToDie().
Variable Documentation
◆ Asserting_
|
static |
◆ DefaultStderrLevel
|
static |
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 debug.cc.
Referenced by StderrChannel::enabled(), and Debug::EnsureDefaultStderrLevel().
◆ DidResetSections
|
static |
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 debug.cc.
Referenced by DebugModule::DebugModule(), and ResetSections().
◆ EarlyMessagesLevel
|
staticconstexpr |
Definition at line 54 of file debug.cc.
Referenced by DebugChannel::saveMessage().
◆ ExplicitStderrLevel
|
static |
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 debug.cc.
Referenced by StderrChannel::enabled(), Debug::ResetStderrLevel(), and Debug::SettleStderr().
◆ Module_
|
static |
◆ ProcessLabel
|
static |
Definition at line 57 of file debug.cc.
Referenced by LabelThisProcess(), Debug::NameThisKid(), and DebugChannel::writeToStream().
◆ TheLog
|
static |
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 debug.cc.
Referenced by _db_rotate_log(), DebugModule::banCacheLogUse(), debugOpenLog(), DebugStream(), Debug::LogMessage(), DebugModule::prepareToDie(), CacheLogChannel::shouldWrite(), Debug::StopCacheLogUse(), DebugModule::useCacheLog(), and CacheLogChannel::write().
◆ WaitingForIdle
|
static |
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 debug.cc.
Referenced by Debug::Finish(), and Debug::LogWaitingForIdle().