Tomographer
v5.4
Tomographer C++ Framework Documentation
|
Local logger: avoid having to repeat origin at each emitted message. More...
#include <tomographer/tools/loggers.h>
Public Types | |
typedef BaseLoggerType_ | BaseLoggerType |
The base logger type (see class documentation) | |
typedef _PARENT_LOGGER_TYPE | ParentLoggerType |
Type of the parent logger type, ultimately responsible for actually emitting the messages in some useful way. More... | |
Public Types inherited from Tomographer::Logger::LoggerBase< LocalLogger< BaseLoggerType_ > > | |
enum | |
Shortcuts to properties defined in the traits class. | |
Public Member Functions | |
LocalLogger (std::string origin_fn_name, BaseLoggerType &logger_) | |
Construct a local logger. More... | |
LocalLogger (std::string origin_prefix, std::string glue, BaseLoggerType &logger_) | |
Construct a local logger. More... | |
LocalLogger (const LocalLoggerOriginSpec &spec, BaseLoggerType &logger_) | |
Construct a local logger. More... | |
LocalLogger (LocalLogger &&movecopy) | |
LocalLogger (const LocalLogger &other) | |
Make the local-logger copyable – there's nothing wrong with that. | |
std::string | originPrefix () const |
The fixed origin specified at the constructor. More... | |
std::string | glue () const |
The "glue" string to use to concatenate origins from sub-loggers. | |
BaseLoggerType & | baseLogger () |
The base logger type specified to the constructor. More... | |
ParentLoggerType & | parentLogger () |
The parent logger responsible for actually emitting the messages in some useful way. More... | |
LocalLogger< LocalLogger< BaseLoggerType > > | subLogger (std::string new_prefix) |
Create a sub-logger. More... | |
LocalLogger< LocalLogger< BaseLoggerType > > | subLogger (std::string new_prefix, std::string new_glue) |
Create a sub-logger. More... | |
LocalLogger< LocalLogger< BaseLoggerType > > | subLogger (const LocalLoggerOriginSpec &spec) |
Create a sub-logger. More... | |
template<ENABLED_IF( Base_::template staticallyEnabledFor< LONGDEBUG >()) > | |
void | longdebug (const char *fmt,...) |
Generate a log message with level Logger::LONGDEBUG (printf-like syntax) More... | |
template<ENABLED_IF( Base_::template staticallyEnabledFor< DEBUG >()) > | |
void | debug (const char *fmt,...) |
Generate a log message with level Logger::DEBUG (printf-like syntax) More... | |
template<ENABLED_IF( Base_::template staticallyEnabledFor< INFO >()) > | |
void | info (const char *fmt,...) |
Generate a log message with level Logger::INFO (printf-like syntax) More... | |
template<ENABLED_IF( Base_::template staticallyEnabledFor< WARNING >()) > | |
void | warning (const char *fmt,...) |
Generate a log message with level Logger::WARNING (printf-like syntax) More... | |
template<ENABLED_IF( Base_::template staticallyEnabledFor< ERROR >()) > | |
void | error (const char *fmt,...) |
Generate a log message with level Logger::ERROR (printf-like syntax) More... | |
template<ENABLED_IF( Base_::template staticallyEnabledFor< LONGDEBUG >()) , typename... Args> | |
void | longdebug (Args &&... a) |
Generate a log message with level Logger::LONGDEBUG. More... | |
template<ENABLED_IF( Base_::template staticallyEnabledFor< DEBUG >()) , typename... Args> | |
void | debug (Args &&... a) |
Generate a log message with level Logger::DEBUG. More... | |
template<ENABLED_IF( Base_::template staticallyEnabledFor< INFO >()) , typename... Args> | |
void | info (Args &&... a) |
Generate a log message with level Logger::INFO. More... | |
template<ENABLED_IF( Base_::template staticallyEnabledFor< WARNING >()) , typename... Args> | |
void | warning (Args &&... a) |
Generate a log message with level Logger::WARNING. More... | |
template<ENABLED_IF( Base_::template staticallyEnabledFor< ERROR >()) , typename... Args> | |
void | error (Args &&... a) |
Generate a log message with level Logger::ERROR. More... | |
template<int Level, ENABLED_IF( Base_::template staticallyEnabledFor< Level >()) , typename... Args> | |
void | log (Args &&... args) |
Generate a log message with level Level. More... | |
template<ENABLED_IF( !Base_::template staticallyEnabledFor< LONGDEBUG >()) , typename... Args> | |
void | longdebug (Args &&...) |
Statically optimized call if we know at compile time that the message will be discarded. | |
template<ENABLED_IF( !Base_::template staticallyEnabledFor< DEBUG >()) , typename... Args> | |
void | debug (Args &&...) |
Statically optimized call if we know at compile time that the message will be discarded. | |
template<ENABLED_IF( !Base_::template staticallyEnabledFor< INFO >()) , typename... Args> | |
void | info (Args &&...) |
Statically optimized call if we know at compile time that the message will be discarded. | |
template<ENABLED_IF( !Base_::template staticallyEnabledFor< WARNING >()) , typename... Args> | |
void | warning (Args &&...) |
Statically optimized call if we know at compile time that the message will be discarded. | |
template<ENABLED_IF( !Base_::template staticallyEnabledFor< ERROR >()) , typename... Args> | |
void | error (Args &&...) |
Statically optimized call if we know at compile time that the message will be discarded. | |
template<int Level, ENABLED_IF( !Base_::template staticallyEnabledFor< Level >()) , typename... Args> | |
void | log (Args &&...) |
Statically optimized call if we know at compile time that the message will be discarded. | |
std::string | getSubOrigin (const char *origin) const |
The full origin string to use for a sub-logger. More... | |
void | emitLog (int level, const char *origin, std::string msg) |
Emit a log by relaying to the base logger. | |
int | level () const |
Get the base logger's set level. | |
template<ENABLED_IF( Tomographer::Logger::LoggerTraits< BaseLoggerType >::HasFilterByOrigin) > | |
bool | filterByOrigin (int level, const char *origin) |
If relevant for the base logger, filter the messages by origin from the base logger. | |
Public Member Functions inherited from Tomographer::Logger::LoggerBase< LocalLogger< BaseLoggerType_ > > | |
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 | |
Static Public Member Functions inherited from Tomographer::Logger::LoggerBase< LocalLogger< BaseLoggerType_ > > | |
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< LocalLogger< BaseLoggerType_ > > | |
int | getLevel () const |
int | getLevel () const |
LocalLogger< BaseLoggerType_ > * | derived () |
const LocalLogger< BaseLoggerType_ > * | derived () const |
void | setLogLevel (int level) |
Store a new run-time log level. More... | |
Local logger: avoid having to repeat origin at each emitted message.
This type of logger accepts origin information in its constructor. Then, you may call the longdebug(), debug(), info(), warning() and error() methods without having to specify the origin information, which is known from the constructor.
This logger is to be used with another logger instance, which is actually responsible for producing the log messages. This logger then relays log messages that base logger instance, of type BaseLoggerType (for example, FileLogger, BufferLogger etc.).
You may also nest these loggers, yielding an automatic nested origin string following C++ names. See method subLogger(std::string) for more info. In case of nesting, what happens is that the BaseLoggerType is a LocalLogger itself.
A very handy shorthand is makeLocalLogger(), which allows to spare some typing (see documentation for makeLocalLogger()).
The macro TOMO_ORIGIN is particularly useful for this class, as you can specify it in the origin parameter to automatically yield the name of the current method.
Example usage:
typedef _PARENT_LOGGER_TYPE Tomographer::Logger::LocalLogger< BaseLoggerType_ >::ParentLoggerType |
Type of the parent logger type, ultimately responsible for actually emitting the messages in some useful way.
See parentLogger().
|
inline |
Construct a local logger.
origin_fn_name | is the origin you want to associate with log messages generated by this logger. You may also use the macro TOMO_ORIGIN for this argument to automatically set the origin to the current function or method name. |
logger_ | is a logger instance of type BaseLoggerType, which is responsible for actually emitting the messages in some useful way (e.g. it may be a FileLogger, BufferLogger, etc.) |
|
inline |
Construct a local logger.
See LocalLogger(std::string, BaseLoggerType&). This overload allows you to also specify the glue to use when concatenating origins for sub-loggers, see glue() and subLogger().
|
inline |
Construct a local logger.
See LocalLogger(std::string, BaseLoggerType&). This overload is the one which is called if you use the macro TOMO_ORIGIN for the first argument.
|
inline |
We need this for makeLocalLogger().
|
inline |
The base logger type specified to the constructor.
If we are a sub-logger of another local logger, then BaseLoggerType is itself also a LocalLogger.
|
inline |
Generate a log message with level Logger::DEBUG (printf-like syntax)
The origin parameter is automatically set, and is not specified here.
|
inline |
Generate a log message with level Logger::DEBUG.
The origin parameter is automatically set, and is not specified here.
|
inline |
Generate a log message with level Logger::ERROR (printf-like syntax)
The origin parameter is automatically set, and is not specified here.
|
inline |
Generate a log message with level Logger::ERROR.
The origin parameter is automatically set, and is not specified here.
|
inline |
The full origin string to use for a sub-logger.
This simply returns the concatenation of originPrefix() with origin using the glue().
It is the full origin parameter which is used when creating sub-loggers of this logger (see subLogger()).
|
inline |
Generate a log message with level Logger::INFO (printf-like syntax)
The origin parameter is automatically set, and is not specified here.
|
inline |
Generate a log message with level Logger::INFO.
The origin parameter is automatically set, and is not specified here.
|
inline |
|
inline |
Generate a log message with level Logger::LONGDEBUG (printf-like syntax)
The origin parameter is automatically set, and is not specified here.
|
inline |
Generate a log message with level Logger::LONGDEBUG.
The origin parameter is automatically set, and is not specified here.
|
inline |
The fixed origin specified at the constructor.
This will be used as origin if you call one of the logging functions longdebug(), debug(), info(), warning(), error() or log<LEVEL>().
This string will also be used as a "prefix" for sub-loggers.
|
inline |
The parent logger responsible for actually emitting the messages in some useful way.
This function returns baseLogger() if the BaseLoggerType is not a LocalLogger. Otherwise, it follows the base loggers of the LocalLoggers until a non-LocalLogger parent is found; the latter is returned.
|
inline |
Create a sub-logger.
The origin of the messages generated by this new sub-logger will be the concatenation of the parent (this) logger's origin, with the new_prefix, using the parent (this) object's glue() string.
You may use the macro TOMO_ORIGIN as argument here to automatically set the origin to the current function or method name.
|
inline |
Create a sub-logger.
See subLogger(std::string). This overload allows to specify the new object's glue string, which will be used in case the sub-logger itself becomes parent to a (sub-)sub-logger.
|
inline |
Create a sub-logger.
See subLogger(std::string). This overload is called when the macro TOMO_ORIGIN is specified.
|
inline |
Generate a log message with level Logger::WARNING (printf-like syntax)
The origin parameter is automatically set, and is not specified here.
|
inline |
Generate a log message with level Logger::WARNING.
The origin parameter is automatically set, and is not specified here.