Abstract logger; downstream supplies an implementation. More...
#include <logger.hpp>
Public Member Functions | |
| Logger ()=default | |
| virtual | ~Logger ()=default |
| Logger (const Logger &)=delete | |
| Logger & | operator= (const Logger &)=delete |
| Logger (Logger &&)=delete | |
| Logger & | operator= (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 | |
| 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} |
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.
|
default |
|
virtualdefault |
|
delete |
|
delete |
|
inline |
|
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.
|
inline |
|
inlinenoexcept |
|
inline |
|
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.
|
inlinenoexcept |
|
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.
|
inline |
|
inline |
|
protected |