Tomographer
v1.0a
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 | emit_log (int level, const char *origin, const std::string &msg) |
Emit a log message (relay to base logger). More... | |
bool | filter_by_origin (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... | |
void | error (const char *origin, const char *fmt,...) |
emit an error message More... | |
void | error (const char *origin, const std::string &msg) |
emit an error message More... | |
void | error (const char *origin, Fn f) |
emit an error message More... | |
void | warning (const char *origin, const char *fmt,...) |
emit a warning message More... | |
void | warning (const char *origin, const std::string &msg) |
emit a warning message More... | |
void | warning (const char *origin, Fn f) |
emit a warning message More... | |
void | info (const char *origin, const char *fmt,...) |
emit an information/notice message More... | |
void | info (const char *origin, const std::string &msg) |
emit an information/notice message More... | |
void | info (const char *origin, Fn f) |
emit an information/notice message More... | |
void | debug (const char *origin, const char *fmt,...) |
emit an debug message More... | |
void | debug (const char *origin, const std::string &msg) |
emit an debug message More... | |
void | debug (const char *origin, Fn f) |
emit an debug message More... | |
void | longdebug (const char *origin, const char *fmt,...) |
emit a very verbose debugging message More... | |
void | longdebug (const char *origin, const 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 | 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, const 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, const 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... | |
bool | enabled_for (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... | |
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 | statically_enabled_for (int level) |
Check whether the logger is statically disabled for some levels. More... | |
static bool | statically_enabled_for () |
Static version of statically_enabled_for() 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 |
Constructor based on a base logger reference.
Pass a reference to the base logger here. Calls to emit_log(), etc., will be relayed to this base logger.
|
inline |
Emit a log message (relay to base logger).
Simply relay the call to the base logger instance's emit_log().
|
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<BaseLogger>::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 filter_by_origin() gets called. So we return LOWEST_SEVERITY_LEVEL here to "trick" the logging engine, and use the base logger's level() only in filter_by_origin().
|
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.