nidas v1.2.3
|
A configuration to enable or disable a matching set of log points. More...
#include <Logger.h>
Public Member Functions | |
bool | matches (const LogContext &lc) const |
Return true if this config matches the given LogContext lc . | |
LogConfig & | parse (const std::string &text) |
Parse LogConfig settings from a string specifier, using comma-separated fields to assign to each of the config fields. | |
LogConfig (const std::string &text="") | |
Construct a default LogConfig which matches and enables every log point with level DEBUG or higher. | |
Public Attributes | |
std::string | filename_match |
Apply this config to log points in filenames which contain the given string. | |
std::string | function_match |
Apply this config to log points in functions which contain the given string. | |
std::string | tag_match |
Apply this config to log points whose tags include this tag. | |
int | line |
Apply this config to log points with the given line number. | |
int | level |
For all matching log points, enable the log point if the log level is more severe (lower value) than this threshold level. | |
bool | activate |
If true, then all matching log points will be enabled. | |
A configuration to enable or disable a matching set of log points.
A LogConfig specifies which log points to match and whether to activate or disable them. The set of log points are matched by filename, function name, line number, and level. For example, all the log messages in a given file can be enabled with a LogConfig that sets filename_match
to the filename and level
to LOGGER_DEBUG
. Methods within an object all include the class name in the function signature, so those can be enabled with a function_match set to the class name. The default LogConfig matches every log point with threshold DEBUG or lower, ie, not VERBOSE messages. File and function names are matched as substrings, so a function_match
set to "Logger::" will match all methods of the Logger class.
LogConfig::LogConfig | ( | const std::string & | text = "" | ) |
bool LogConfig::matches | ( | const LogContext & | lc | ) | const |
Return true if this config matches the given LogContext lc
.
References filename_match, function_match, level, line, and tag_match.
LogConfig & LogConfig::parse | ( | const std::string & | text | ) |
Parse LogConfig settings from a string specifier, using comma-separated fields to assign to each of the config fields.
Throws std::runtime_error if the text fails to parse. Passing an empty string has no effect.
Return a reference to this LogConfig, so it can chained to construct a LogConfig from a string like so:
LogScheme().addConfig(LogConfig().parse(text))
Here are the fields:
This example enables all log messages for filenames which contain the string 'TwoD':
verbose,file=TwoD
Enable all debug messages in the core library:
debug,file=nidas/core
References activate, filename_match, function_match, level, line, parse_log_level(), and tag_match.
Referenced by LogConfig().
bool nidas::util::LogConfig::activate |
If true, then all matching log points will be enabled.
If false, any matching log points will be disabled.
Referenced by parse().
std::string nidas::util::LogConfig::filename_match |
std::string nidas::util::LogConfig::function_match |
int nidas::util::LogConfig::level |
For all matching log points, enable the log point if the log level is more severe (lower value) than this threshold level.
The default threshold includes all log levels.
Referenced by get_scheme(), matches(), and parse().
int nidas::util::LogConfig::line |
std::string nidas::util::LogConfig::tag_match |