debug.cc
Go to the documentation of this file.
593DebugChannel::saveMessage(const DebugMessageHeader &header, const CompiledDebugMessageBody &body)
612DebugChannel::writeToStream(FILE &destination, const DebugMessageHeader &header, const CompiledDebugMessageBody &body)
733DebugMessageHeader::DebugMessageHeader(const DebugRecordCount aRecordNumber, const Debug::Context &context):
1206 debugs(0, DBG_IMPORTANT, "ERROR: removal of log file " << to << " failed: " << xstrerr(saved_errno));
1237 const auto sz = snprintf(buf, sizeof(buf), "%s.%03d", buf2, static_cast<int>(t.tv_usec / 1000));
1266 debugs(0, DBG_CRITICAL, "FATAL: assertion failed: " << file << ":" << line << ": \"" << msg << "\"");
std::ostream & CurrentCodeContextDetail(std::ostream &os)
Definition: CodeContext.cc:96
void log(char *format,...)
DebugChannel managing messages destined for the configured cache_log file.
Definition: debug.cc:239
void write(const DebugMessageHeader &, const CompiledDebugMessageBody &) final
write the corresponding debugs() message into the channel
Definition: debug.cc:637
bool shouldWrite(const DebugMessageHeader &) const final
Definition: debug.cc:631
CompiledDebugMessage(const Header &, const Body &)
Definition: debug.cc:745
output iterator for writing CompiledDebugMessages to a given channel
Definition: debug.cc:175
Logger & operator=(const CompiledDebugMessage &message)
Definition: debug.cc:185
std::output_iterator_tag iterator_category
Definition: debug.cc:181
DebugChannel(DebugChannel &&)=delete
DebugRecordCount written
the number of messages sent to the underlying channel so far
Definition: debug.cc:226
void saveMessage(const DebugMessageHeader &, const CompiledDebugMessageBody &)
stores the given early message (if possible) or forgets it (otherwise)
Definition: debug.cc:593
static void StopSavingAndLog(DebugChannel &, DebugChannel *=nullptr)
stop saving and log() any "early" messages, in recordNumber order
Definition: debug.cc:568
void noteWritten(const DebugMessageHeader &)
reacts to a written a debugs() message
Definition: debug.cc:622
void writeToStream(FILE &, const DebugMessageHeader &, const CompiledDebugMessageBody &)
Formats a validated debugs() record and writes it to the given FILE.
Definition: debug.cc:612
virtual ~DebugChannel()=default
void log(const DebugMessageHeader &, const CompiledDebugMessageBody &)
Definition: debug.cc:536
std::unique_ptr< CompiledDebugMessages > EarlyMessages
Definition: debug.cc:150
void stopEarlyMessageCollection()
end early message buffering, logging any saved messages
Definition: debug.cc:528
bool collectingEarlyMessages() const
whether we are still expecting (and buffering) early messages
Definition: debug.cc:159
virtual void write(const DebugMessageHeader &, const CompiledDebugMessageBody &)=0
write the corresponding debugs() message into the channel
DebugRecordCount lastWrittenRecordNumber
DebugMessageHeader::recordNumber of the last message we wrote.
Definition: debug.cc:229
virtual bool shouldWrite(const DebugMessageHeader &) const =0
friend void ResyncDebugLog(FILE *newFile)
a hack for low-level file descriptor manipulations in ipcCreate()
Definition: debug.cc:514
DebugFile(DebugFile &&)=delete
void reset(FILE *newFile, const char *newName)
switches to the new pair, absorbing FILE and duping the name
Definition: debug.cc:754
DebugMessageHeader(const DebugRecordCount aRecordNumber, const Debug::Context &)
Definition: debug.cc:733
Definition: debug.cc:296
~DebugModule()=delete
void log(const DebugMessageHeader &, const CompiledDebugMessageBody &)
Definition: debug.cc:446
void rewind(const int aSection, const int aLevel)
Optimization: avoids new Context creation for every debugs().
Definition: debug.cc:1287
static void ForgetSaved()
silently erases saved early debugs() messages (if any)
Definition: debug.cc:553
static bool Enabled(const int section, const int level)
whether debugging the given section and the given level produces output
Definition: Stream.h:75
static void LogMessage(const Context &)
broadcasts debugs() message to the logging channels
Definition: debug.cc:778
static void Finish()
logs output buffer created in Start() and closes debugging context
Definition: debug.cc:1363
static void FormatStream(std::ostream &)
configures default formatting for the debugging stream
Definition: debug.cc:1302
static std::ostringstream & Start(const int section, const int level)
opens debugging context and returns output buffer
Definition: debug.cc:1339
static void ConfigureSyslog(const char *facility)
enables logging to syslog (using the specified facility, when not nil)
Definition: debug.cc:1080
static void EnsureDefaultStderrLevel(int maxDefault)
Definition: debug.cc:692
static void LogWaitingForIdle()
Logs messages of Finish()ed debugs() calls that were queued earlier.
Definition: debug.cc:1324
static void ForceAlert()
configures the active debugging context to write syslog ALERT
Definition: debug.cc:1400
Definition: debug.cc:329
static size_t LoggingConcurrencyLevel
the current number of protected callers
Definition: debug.cc:339
DebugChannel managing messages destined for "standard error stream" (stderr)
Definition: debug.cc:251
bool shouldWrite(const DebugMessageHeader &) const final
Definition: debug.cc:660
void takeOver(CacheLogChannel &)
start to take care of past/saved and future cacheLovirtual gChannel messages
Definition: debug.cc:672
void write(const DebugMessageHeader &, const CompiledDebugMessageBody &) final
write the corresponding debugs() message into the channel
Definition: debug.cc:666
void stopCoveringForCacheLog()
stop providing a cache_log replacement (if we were providing it)
Definition: debug.cc:682
bool coveringForCacheLog
whether we are the last resort for logging debugs() messages
Definition: debug.cc:271
bool shouldWrite(const DebugMessageHeader &) const final
Definition: debug.cc:1070
void write(const DebugMessageHeader &, const CompiledDebugMessageBody &) final
write the corresponding debugs() message into the channel
Definition: debug.cc:1062
void ResyncDebugLog(FILE *newFile)
a hack for low-level file descriptor manipulations in ipcCreate()
Definition: debug.cc:514
std::deque< CompiledDebugMessage > CompiledDebugMessages
debugs() messages captured in LogMessage() call order
Definition: debug.cc:144
static void LabelThisProcess(const char *const name, const std::optional< int > id=std::optional< int >())
optimization: formats ProcessLabel once for frequent debugs() reuse
Definition: debug.cc:369
static std::string ProcessLabel
pre-formatted name of the current process for debugs() messages (or empty)
Definition: debug.cc:58
static void ResetSections(const int level=DBG_IMPORTANT)
used for the side effect: fills Debug::Levels with the given level
Definition: debug.cc:360
static constexpr int EarlyMessagesLevel
early debugs() with higher level are not buffered and, hence, may be lost
Definition: debug.cc:55
std::string CompiledDebugMessageBody
The processed "content" (i.e. the last parameter) part of a debugs() call.
Definition: debug.cc:125
time_t getCurrentTime() STUB_RETVAL(0) int tvSubUsec(struct timeval
struct timeval current_time
the current UNIX time in timeval {seconds, microseconds} format
Definition: gadgets.cc:17