Tomographer
v5.2
Tomographer C++ Framework Documentation
|
A logger which filters entries according to where they originated from. More...
#include <tomographer/tools/loggers.h>
Public Member Functions | |
OriginFilteredLogger (BaseLogger &baselogger_) | |
Constructor based on a base logger reference. More... | |
void | setDomainLevel (const std::string &origin_pattern, int level) |
Set a rule to log messages based on their origin. More... | |
void | removeDomainSetting (const std::string &s) |
Remove a rule set by setDomainLevel() More... | |
int | level () const |
Unconditionally return LOWEST_SEVERITY_LEVEL for the underlying logging engine. More... | |
void | emitLog (int level, const char *origin, std::string msg) |
Emit a log message (relay to base logger). More... | |
bool | filterByOrigin (int level, const char *origin) const |
Message filtering by origin implementation. More... | |
Public Member Functions inherited from Tomographer::Logger::LoggerBase< OriginFilteredLogger< BaseLogger > > | |
LoggerBase (int level_=INFO) | |
Construct the base logger object. More... | |
bool | enabledFor (int level_) const |
Check whether messages at the given log level are enabled. More... | |
int | level () const |
Get the log level set for this logger. More... | |
void | error (const char *origin, const char *fmt,...) |
emit an error message More... | |
void | error (const char *origin, std::string msg) |
emit an error message More... | |
void | error (const char *origin, Fn &&f) |
emit an error message More... | |
void | error (Args &&...) |
Special-case implementation for messages which are known to be discarded at compile time. | |
void | warning (const char *origin, const char *fmt,...) |
emit a warning message More... | |
void | warning (const char *origin, std::string msg) |
emit a warning message More... | |
void | warning (const char *origin, Fn &&f) |
emit a warning message More... | |
void | warning (Args &&...) |
Special-case implementation for messages which are known to be discarded at compile time. | |
void | info (const char *origin, const char *fmt,...) |
emit an information/notice message More... | |
void | info (const char *origin, std::string msg) |
emit an information/notice message More... | |
void | info (const char *origin, Fn &&f) |
emit an information/notice message More... | |
void | info (Args &&...) |
Special-case implementation for messages which are known to be discarded at compile time. | |
void | debug (const char *origin, const char *fmt,...) |
emit an debug message More... | |
void | debug (const char *origin, std::string msg) |
emit an debug message More... | |
void | debug (const char *origin, Fn &&f) |
emit an debug message More... | |
void | debug (Args &&...) |
Special-case implementation for messages which are known to be discarded at compile time. | |
void | longdebug (const char *origin, const char *fmt,...) |
emit a very verbose debugging message More... | |
void | longdebug (const char *origin, std::string msg) |
emit a very verbose debugging message More... | |
void | longdebug (const char *origin, Fn &&f) |
emit a very verbose debugging message More... | |
void | longdebug (Args &&...) |
Special-case implementation for messages which are known to be discarded at compile time. | |
void | log (int level, const char *origin, const char *fmt,...) |
emit a log message at the given log level. More... | |
void | log (int level, const char *origin, std::string msg) |
emit a log message at the given log level. More... | |
void | log (int level, const char *origin, Fn &&f) |
emit a log message at the given log level. More... | |
void | log (const char *origin, const char *fmt,...) |
emit a log message at the given log level. More... | |
void | log (const char *origin, const char *fmt, va_list ap) |
emit a log message at the given log level. More... | |
void | log (const char *origin, std::string msg) |
emit a log message at the given log level. More... | |
void | log (const char *origin, Fn f) |
emit a log message at the given log level. More... | |
void | log (Args &&...) |
Special-case implementation for messages which are known to be discarded at compile time. | |
Additional Inherited Members | |
Public Types inherited from Tomographer::Logger::LoggerBase< OriginFilteredLogger< BaseLogger > > | |
enum | |
Shortcuts to properties defined in the traits class. | |
Static Public Member Functions inherited from Tomographer::Logger::LoggerBase< OriginFilteredLogger< BaseLogger > > | |
static bool | staticallyEnabledFor (int level) |
Check whether the logger is statically disabled for some levels. More... | |
static constexpr bool | staticallyEnabledFor () |
Static version of staticallyEnabledFor() More... | |
Protected Member Functions inherited from Tomographer::Logger::LoggerBase< OriginFilteredLogger< BaseLogger > > | |
int | getLevel () const |
int | getLevel () const |
OriginFilteredLogger< BaseLogger > * | derived () |
const OriginFilteredLogger< BaseLogger > * | derived () const |
void | setLogLevel (int level) |
Store a new run-time log level. More... | |
A logger which filters entries according to where they originated from.
This logger implementation logs messages at specific severity levels depending on the origin of the messages.
Use setDomainLevel() to set specific log levels to particular origin patterns. Each pattern given to setDomainLevel() is a string: if the origin of a particular messages starts with this string, then the log level is applied. If no rules apply, the level of the base logger (the one we act as proxy to) is used.
This logger acts as a proxy for another logger implementation. For example, you can do:
|
inline |
|
inline |
|
inline |
Message filtering by origin implementation.
This function returns true
if the message should be emitted, given the set of rules set by previous calls to setDomainLevel().
See also LoggerTraits::HasFilterByOrigin.
|
inline |
Unconditionally return LOWEST_SEVERITY_LEVEL for the underlying logging engine.
This level() is used to pre-filter all the log messages, before our filterByOrigin() gets called. So we return LOWEST_SEVERITY_LEVEL here to "trick" the logging engine, and use the base logger's level() only in filterByOrigin().
|
inline |
Remove a rule set by setDomainLevel()
s | the origin pattern corresponding to the rule to erase. This must be a pattern previously passed to setDomainLevel(). |
|
inline |
Set a rule to log messages based on their origin.
Messages whose origin start with the substring origin_pattern will be emitted only if they are at least of severity level. (The rule corresponding to the longest pattern, i.e. the most specific pattern, is always the one which is applied.)
Calling this function several times with the same pattern replaces the previous setting.