OpenVPN 3 Core Library
|
#include <logger.hpp>
Public Member Functions | |
int | log_level () const |
return the current logging level for all logging | |
void | set_log_level (int level) |
set the log level for all loggigng | |
std::string | log_prefix () const |
return the current prefix all logging | |
void | set_log_prefix (const std::string &prefix) |
set the log prefix for all loggigng | |
template<int LEVEL, typename T > | |
void | log (T &&msg) const |
template<typename T > | |
void | log_trace (T &&msg) const |
template<typename T > | |
void | log_debug (T &&msg) const |
template<typename T > | |
void | log_info (T &&msg) const |
template<typename T > | |
void | log_verbose (T &&msg) const |
template<typename T > | |
void | log_error (T &&msg) const |
Static Public Attributes | |
static constexpr int | max_log_level = std::max(MAX_LEVEL, DEFAULT_LOG_LEVEL) |
static constexpr int | default_log_level = DEFAULT_LOG_LEVEL |
Protected Attributes | |
int | current_log_level = DEFAULT_LOG_LEVEL |
configured loglevel | |
std::string | prefix_ |
A class that simplifies the logging with different verbosity. It is intended to be either used as a base class or preferably as a member. The member can be either a normal member or static member depending if setting the loglevel should affect all instances of the class or only the current one.
e.g.:
static inline logging::Logger<logging::LOG_LEVEL_INFO, logging::LOG_LEVEL_VERB> log_;
and then when logging in the class use
DEFAULT_LOG_LEVEL | the default loglevel for this class |
MAX_LEVEL | the maximum loglevel that will be printed. Logging with higher verbosity will be disabled by using if constexpr expressions. Will be ignored and set to DEFAULT_LOG_LEVEL if DEFAULT_LOG_LEVEL is higher than MAX_LEVEL. |
This allows to customise compile time maximum verbosity.
A mixin class that can be used as base class to expose the setting and getting of the log level publicly but not expose the log methods themselves. Class parameters are the same as for
Definition at line 53 of file logger.hpp.
|
inline |
Prints a log message for tracing if the log level is at least LEVEL.
msg | the message to print |
Definition at line 90 of file logger.hpp.
|
inline |
Prints a log message for debugging only info if the log level is at least DEBUG (=3)
msg | the message to print |
Definition at line 117 of file logger.hpp.
|
inline |
Logs an error message that should almost always be logged
msg | the message to log |
Definition at line 148 of file logger.hpp.
|
inline |
Prints a log message for general info if the log level is at least INFO (=1)
msg | the message to print |
Definition at line 128 of file logger.hpp.
|
inline |
return the current logging level for all logging
Definition at line 61 of file logger.hpp.
|
inline |
return the current prefix all logging
Definition at line 73 of file logger.hpp.
|
inline |
Prints a log message for tracing if the log level is at least TRACE (=4)
msg | the message to print |
Definition at line 106 of file logger.hpp.
|
inline |
Prints a verbose log message if the log level is at least VERB (=2)
msg | the message to log |
Definition at line 138 of file logger.hpp.
|
inline |
set the log level for all loggigng
Definition at line 67 of file logger.hpp.
|
inline |
set the log prefix for all loggigng
Definition at line 79 of file logger.hpp.
|
protected |
configured loglevel
Definition at line 155 of file logger.hpp.
|
staticconstexpr |
Definition at line 57 of file logger.hpp.
|
staticconstexpr |
Definition at line 56 of file logger.hpp.
|
protected |
Definition at line 156 of file logger.hpp.