ifw-fnd 2.0.1
 
Loading...
Searching...
No Matches
ifw::fnd::Logger Class Referenceabstract

Abstract logger; downstream supplies an implementation. More...

#include <logger.hpp>

Public Member Functions

 Logger ()=default
 
virtual ~Logger ()=default
 
 Logger (const Logger &)=delete
 
Loggeroperator= (const Logger &)=delete
 
 Logger (Logger &&)=delete
 
Loggeroperator= (Logger &&)=delete
 
virtual void Emit (LogLevel level, const std::string &message)=0
 Deliver one already-formatted log line.
 
virtual void Throw (const std::string &message)
 Log at error level and then throw.
 
virtual std::vector< std::string > ListSources () const
 Enumerate the named log sources this backend knows about.
 
void SetLogLevel (LogLevel level) noexcept
 
LogLevel GetLogLevel () const noexcept
 
Convenience wrappers

These funnel through Emit() and are provided so that call-site code reads naturally without naming the level enum. The FND* macros use them.

void Trace (const std::string &m)
 
void Debug (const std::string &m)
 
void Info (const std::string &m)
 
void Warning (const std::string &m)
 
void Error (const std::string &m)
 

Protected Attributes

LogLevel m_level {LogLevel::INFO}
 

Detailed Description

Abstract logger; downstream supplies an implementation.

Subclasses must override Emit() (and may override Throw() to customise the exception type or to perform side-effects such as errAdd before throwing). All other methods are convenience wrappers that funnel through Emit().

Implementations are free to add their own filtering on top of the threshold maintained here (e.g. CII's per-logger config). The threshold on this base class governs the early-out in the FND* macros — its purpose is to keep disabled-level log calls cheap, not to be the single source of truth for routing decisions in the underlying backend.

Constructor & Destructor Documentation

◆ Logger() [1/3]

ifw::fnd::Logger::Logger ( )
default

◆ ~Logger()

virtual ifw::fnd::Logger::~Logger ( )
virtualdefault

◆ Logger() [2/3]

ifw::fnd::Logger::Logger ( const Logger & )
delete

◆ Logger() [3/3]

ifw::fnd::Logger::Logger ( Logger && )
delete

Member Function Documentation

◆ Debug()

void ifw::fnd::Logger::Debug ( const std::string & m)
inline

◆ Emit()

virtual void ifw::fnd::Logger::Emit ( LogLevel level,
const std::string & message )
pure virtual

Deliver one already-formatted log line.

Subclasses route this to their backend (log4cplus, CII, VLT cutePRINT, stdout, …). message has no trailing newline; backends add one if their format requires it.

◆ Error()

void ifw::fnd::Logger::Error ( const std::string & m)
inline

◆ GetLogLevel()

LogLevel ifw::fnd::Logger::GetLogLevel ( ) const
inlinenoexcept

◆ Info()

void ifw::fnd::Logger::Info ( const std::string & m)
inline

◆ ListSources()

virtual std::vector< std::string > ifw::fnd::Logger::ListSources ( ) const
inlinevirtual

Enumerate the named log sources this backend knows about.

"Source" means a named origin of log messages in the backend's hierarchy — what log4cplus / CII / Python's logging module all call a "logger". The name "Source" is used here to avoid colliding with Logger (the abstract sink) which is overloaded enough already.

Default implementation returns an empty vector; backends that do have a named-source registry (log4cplus, CII) override this to return the registered names. Pure sink backends (MakeStdoutLogger, MakeNullLogger) correctly return empty — they have no notion of named sources.

Tools call this to implement a generic --list-sources / --list-loggers flag that works across every backend without committing to a concrete logging library.

◆ operator=() [1/2]

Logger & ifw::fnd::Logger::operator= ( const Logger & )
delete

◆ operator=() [2/2]

Logger & ifw::fnd::Logger::operator= ( Logger && )
delete

◆ SetLogLevel()

void ifw::fnd::Logger::SetLogLevel ( LogLevel level)
inlinenoexcept

◆ Throw()

void ifw::fnd::Logger::Throw ( const std::string & message)
virtual

Log at error level and then throw.

Default implementation emits at ERROR and throws std::runtime_error. Subclasses may override to throw a different exception type or to record the error in a platform-specific error stack (e.g. VLT errAdd) before throwing.

◆ Trace()

void ifw::fnd::Logger::Trace ( const std::string & m)
inline

◆ Warning()

void ifw::fnd::Logger::Warning ( const std::string & m)
inline

Member Data Documentation

◆ m_level

LogLevel ifw::fnd::Logger::m_level {LogLevel::INFO}
protected

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