RSTools 3.1.0
Versatile C++20 utility library
Loading...
Searching...
No Matches
RST::Log::ASink Class Referenceabstract

Base class for sinks: handles the level, the pattern and the locking. More...

#include <RST/log/Sinks/ASink.hpp>

Inheritance diagram for RST::Log::ASink:
RST::Log::ISink RST::Log::CallbackSink RST::Log::ConsoleSink RST::Log::DebuggerSink RST::Log::FileSink RST::Log::NullSink RST::Log::OStreamSink RST::Log::RingBufferSink RST::Log::RotatingFileSink RST::Log::SessionFileSink

Public Member Functions

 ASink ()
 
 ~ASink () override
 
void write (const LogMessage &message) final
 Receives a message from a logger.
 
void flush () final
 
void setLevel (LogLevel level) noexcept final
 Minimum level accepted by this sink.
 
LogLevel getLevel () const noexcept final
 
bool shouldLog (LogLevel level) const noexcept final
 
void setFormatter (std::shared_ptr< Formatter > formatter) final
 Shares a Formatter between sinks.
 
void setPattern (std::string_view pattern) final
 Formats the messages with pattern; see Formatter.
 
- Public Member Functions inherited from RST::Log::ISink
virtual ~ISink ()=default
 

Protected Member Functions

virtual void log (const LogMessage &message)=0
 Writes one message; called with the sink mutex locked.
 
virtual void flushSink ()
 Flushes the output; called with the sink mutex locked.
 
std::string_view formatted (const LogMessage &message)
 The message formatted with the sink pattern.
 
std::mutex & sinkMutex () noexcept
 

Detailed Description

Base class for sinks: handles the level, the pattern and the locking.

Subclasses only implement log(), and flushSink() if they buffer their output.

Constructor & Destructor Documentation

◆ ASink()

RST::Log::ASink::ASink ( )

◆ ~ASink()

RST::Log::ASink::~ASink ( )
override

Member Function Documentation

◆ write()

void RST::Log::ASink::write ( const LogMessage &  message)
finalvirtual

Receives a message from a logger.

Implements RST::Log::ISink.

◆ flush()

void RST::Log::ASink::flush ( )
finalvirtual

Implements RST::Log::ISink.

◆ setLevel()

void RST::Log::ASink::setLevel ( LogLevel  level)
inlinefinalvirtualnoexcept

Minimum level accepted by this sink.

Implements RST::Log::ISink.

◆ getLevel()

LogLevel RST::Log::ASink::getLevel ( ) const
inlinefinalvirtualnoexcept

Implements RST::Log::ISink.

◆ shouldLog()

bool RST::Log::ASink::shouldLog ( LogLevel  level) const
inlinefinalvirtualnoexcept

Implements RST::Log::ISink.

◆ setFormatter()

void RST::Log::ASink::setFormatter ( std::shared_ptr< Formatter >  formatter)
finalvirtual

Shares a Formatter between sinks.

Implements RST::Log::ISink.

◆ setPattern()

void RST::Log::ASink::setPattern ( std::string_view  pattern)
finalvirtual

Formats the messages with pattern; see Formatter.

Implements RST::Log::ISink.

◆ log()

virtual void RST::Log::ASink::log ( const LogMessage &  message)
protectedpure virtual

◆ flushSink()

virtual void RST::Log::ASink::flushSink ( )
inlineprotectedvirtual

Flushes the output; called with the sink mutex locked.

Reimplemented in RST::Log::ConsoleSink, RST::Log::FileSink, RST::Log::OStreamSink, RST::Log::RotatingFileSink, and RST::Log::SessionFileSink.

◆ formatted()

std::string_view RST::Log::ASink::formatted ( const LogMessage &  message)
protected

The message formatted with the sink pattern.

◆ sinkMutex()

std::mutex & RST::Log::ASink::sinkMutex ( )
inlineprotectednoexcept

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