a receiver of debugs() messages (e.g., stderr or cache.log) More...

Inheritance diagram for DebugChannel:
Collaboration diagram for DebugChannel:

Classes

class  Logger
 output iterator for writing CompiledDebugMessages to a given channel More...
 

Public Types

using EarlyMessages = std::unique_ptr< CompiledDebugMessages >
 

Public Member Functions

 DebugChannel (const char *aName)
 
virtual ~DebugChannel ()=default
 
 DebugChannel (DebugChannel &&)=delete
 
bool collectingEarlyMessages () const
 whether we are still expecting (and buffering) early messages More...
 
void stopEarlyMessageCollection ()
 end early message buffering, logging any saved messages More...
 
EarlyMessages releaseEarlyMessages ()
 
void log (const DebugMessageHeader &, const CompiledDebugMessageBody &)
 

Protected Member Functions

virtual bool shouldWrite (const DebugMessageHeader &) const =0
 
virtual void write (const DebugMessageHeader &, const CompiledDebugMessageBody &)=0
 write the corresponding debugs() message into the channel More...
 
void saveMessage (const DebugMessageHeader &, const CompiledDebugMessageBody &)
 stores the given early message (if possible) or forgets it (otherwise) More...
 
void writeToStream (FILE &, const DebugMessageHeader &, const CompiledDebugMessageBody &)
 Formats a validated debugs() record and writes it to the given FILE. More...
 
void noteWritten (const DebugMessageHeader &)
 reacts to a written a debugs() message More...
 

Static Protected Member Functions

static void StopSavingAndLog (DebugChannel &, DebugChannel *=nullptr)
 stop saving and log() any "early" messages, in recordNumber order More...
 

Protected Attributes

const char *const name = nullptr
 unique channel label for debugging More...
 
DebugRecordCount written = 0
 the number of messages sent to the underlying channel so far More...
 
DebugRecordCount lastWrittenRecordNumber = 0
 DebugMessageHeader::recordNumber of the last message we wrote. More...
 
EarlyMessages earlyMessages
 

Detailed Description

Definition at line 147 of file debug.cc.

Member Typedef Documentation

◆ EarlyMessages

Definition at line 150 of file debug.cc.

Constructor & Destructor Documentation

◆ DebugChannel() [1/2]

DebugChannel::DebugChannel ( const char *  aName)
explicit

Definition at line 521 of file debug.cc.

◆ ~DebugChannel()

virtual DebugChannel::~DebugChannel ( )
virtualdefault

◆ DebugChannel() [2/2]

DebugChannel::DebugChannel ( DebugChannel &&  )
delete

Member Function Documentation

◆ collectingEarlyMessages()

bool DebugChannel::collectingEarlyMessages ( ) const
inline

Definition at line 159 of file debug.cc.

References earlyMessages.

Referenced by DebugModule::prepareToDie().

◆ log()

void DebugChannel::log ( const DebugMessageHeader header,
const CompiledDebugMessageBody body 
)

Write the message to the channel if the channel accepts (such) messages. This writing may be delayed until the channel configuration is settled.

Definition at line 536 of file debug.cc.

References lastWrittenRecordNumber, DebugMessageHeader::recordNumber, saveMessage(), shouldWrite(), stopEarlyMessageCollection(), and write().

Referenced by DebugModule::log().

◆ noteWritten()

void DebugChannel::noteWritten ( const DebugMessageHeader header)
protected

Definition at line 622 of file debug.cc.

References lastWrittenRecordNumber, DebugMessageHeader::recordNumber, and written.

Referenced by writeToStream().

◆ releaseEarlyMessages()

EarlyMessages DebugChannel::releaseEarlyMessages ( )
inline

end early message buffering, without logging any saved messages

Returns
(a possibly empty container with) saved messages or nil

Definition at line 166 of file debug.cc.

References earlyMessages.

Referenced by StopSavingAndLog().

◆ saveMessage()

void DebugChannel::saveMessage ( const DebugMessageHeader header,
const CompiledDebugMessageBody body 
)
protected

Definition at line 593 of file debug.cc.

References assert, earlyMessages, EarlyMessagesLevel, and DebugMessageHeader::level.

Referenced by log().

◆ shouldWrite()

virtual bool DebugChannel::shouldWrite ( const DebugMessageHeader ) const
protectedpure virtual

whether we should write() the corresponding debugs() message now (assumes some higher-level code applied cache.log section/level filter)

Implemented in CacheLogChannel, StderrChannel, and SyslogChannel.

Referenced by log().

◆ stopEarlyMessageCollection()

void DebugChannel::stopEarlyMessageCollection ( )

◆ StopSavingAndLog()

void DebugChannel::StopSavingAndLog ( DebugChannel channelA,
DebugChannel channelBOrNil = nullptr 
)
staticprotected

◆ write()

virtual void DebugChannel::write ( const DebugMessageHeader ,
const CompiledDebugMessageBody  
)
protectedpure virtual

Implemented in CacheLogChannel, StderrChannel, and SyslogChannel.

Referenced by log().

◆ writeToStream()

void DebugChannel::writeToStream ( FILE &  destination,
const DebugMessageHeader header,
const CompiledDebugMessageBody body 
)
protected

Member Data Documentation

◆ earlyMessages

EarlyMessages DebugChannel::earlyMessages
protected

debugs() messages waiting for the channel configuration to settle (and the channel to open) so that their eligibility for logging can be determined (and the messages can be actually written somewhere)

Definition at line 234 of file debug.cc.

Referenced by collectingEarlyMessages(), releaseEarlyMessages(), saveMessage(), and stopEarlyMessageCollection().

◆ lastWrittenRecordNumber

DebugRecordCount DebugChannel::lastWrittenRecordNumber = 0
protected

Definition at line 229 of file debug.cc.

Referenced by log(), and noteWritten().

◆ name

const char* const DebugChannel::name = nullptr
protected

Definition at line 223 of file debug.cc.

Referenced by StopSavingAndLog().

◆ written

DebugRecordCount DebugChannel::written = 0
protected

Definition at line 226 of file debug.cc.

Referenced by noteWritten(), and StopSavingAndLog().


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

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors