![]() |
SEVN
|
#include <sevnlog.h>
Public Member Functions | |
| SevnLogging () | |
| SevnLogging (int level) | |
| ~SevnLogging () | |
| void | log (int level, std::string errstate, const char *file_input=nullptr, int line_input=-1, int stop=0) const |
| void | debug (std::string errstate, const char *file_input=nullptr, int line_input=-1) const |
| void | info (std::string errstate, const char *file_input=nullptr, int line_input=-1) const |
| void | warning (std::string errstate, const char *file_input=nullptr, int line_input=-1) const |
| void | error (std::string errstate, const char *file_input=nullptr, int line_input=-1, bool stop=true) const |
| template<class E > | |
| void | error (std::string errstate, const char *file_input=nullptr, int line_input=-1, bool stop=true, E &&err=nullptr) const |
| void | critical (std::string errstate, const char *file_input=nullptr, int line_input=-1) const |
| template<class E > | |
| void | critical (std::string errstate, const char *file_input=nullptr, int line_input=-1, E &&err=nullptr) const |
| void | pdebug () const |
| Variadic prints. More... | |
| template<typename T , typename... Tail> | |
| void | pdebug (T head, Tail... tail) const |
| void | pinfo () const |
| template<typename T , typename... Tail> | |
| void | pinfo (T head, Tail... tail) const |
| void | pwarning () const |
| template<typename T , typename... Tail> | |
| void | pwarning (T head, Tail... tail) const |
| int | get_level () |
| unsigned int | get_Ndebug () |
| unsigned int | get_Ninfo () |
| unsigned int | get_Nwarning () |
| unsigned int | get_Nerror () |
| unsigned int | get_Ncustom () |
| void | set_level (std::string level) |
Protected Types | |
| enum | _LOG_LEVEL { _notset = 0 , _debug = 10 , _info = 20 , _warning = 30 , _error = 40 , _critical = 100 } |
Protected Member Functions | |
| void | set_level (int level) |
Static Protected Attributes | |
| static int | log_level = 20 |
| static unsigned int | count_debug =0 |
| static unsigned int | count_info =0 |
| static unsigned int | count_warning =0 |
| static unsigned int | count_error =0 |
| static unsigned int | count_custom_log =0 |
A thread safe(really?) Logging class to handle the message output and the error. It is based on a log level scheme. There is a static attribute log_level that has some integer value by default (20 or 10 id DEBUG has been enabled). Then a given message is sent in output only if its level is larger than log_level. A new log_level can be set with the method set_level. The possible logging message are debug(lvl 10), info(lvl 20), warning(lvl 30), error(lvl 40), critical (no level always printed). Critical raises automatically an exception, while in error is optional. A general log method can be used to print output with a custom level.
|
protected |
|
inline |
Default class constructor.
|
inline |
Class constructor that set the static log level attribute.
| level | log level to set. |
|
inline |
Default class destructor.
| void sevnstd::SevnLogging::critical | ( | std::string | errstate, |
| const char * | file_input = nullptr, |
||
| int | line_input = -1 |
||
| ) | const |
Logs a message with std::cerr level CRITICAL (no level) on this logger and throw an sevnerr exception. This message will never be filtered out.
| errstate | message to log. |
| file_input | Null or FILE. if FILE is used the message logs the name of the file where the log is called. |
| line_input | Null or LINE. if LINE is used the message logs the row number in the file where the log is called. |
|
inline |
Logs a message with std::cerr level CRITICAL (no level) on this logger and throw an exception E.
| E | exception derived from the class sevnerr |
| errstate | message to log. |
| file_input | file_input Null or FILE. if FILE is used the message logs the name of the file where the log is called. |
| line_input | line_input Null or LINE. if LINE is used the message logs the row number in the file where the log is called. |
| err | exception derived from the class sevnerr |
| void sevnstd::SevnLogging::debug | ( | std::string | errstate, |
| const char * | file_input = nullptr, |
||
| int | line_input = -1 |
||
| ) | const |
Logs a message to std::cout with level DEBUG (lvl 10) on this logger.
| errstate | message to log. |
| file_input | Null or FILE. if FILE is used the message logs the name of the file where the log is called. |
| line_input | Null or LINE. if LINE is used the message logs the row number in the file where the log is called. |
| void sevnstd::SevnLogging::error | ( | std::string | errstate, |
| const char * | file_input = nullptr, |
||
| int | line_input = -1, |
||
| bool | stop = true |
||
| ) | const |
Logs a message with std::cerr level ERROR (lvl 40) on this logger and throw an exception.
| errstate | message to log. |
| file_input | Null or FILE. if FILE is used the message logs the name of the file where the log is called. |
| line_input | Null or LINE. if LINE is used the message logs the row number in the file where the log is called. |
| stop | if true throw a sevnerr exception. |
|
inline |
| E | exception derived from the class sevnerr |
| errstate | message to log. |
| file_input | file_input Null or FILE. if FILE is used the message logs the name of the file where the log is called. |
| line_input | line_input Null or LINE. if LINE is used the message logs the row number in the file where the log is called. |
| stop | if if true throw a err exception (see below). |
| err | exception derived from the class sevnerr |
|
inline |
Logs a message to std::cout with level DEBUG (lvl 10) on this logger.
| Args | pack of Variadic arguments |
| args | args to be printed Logs a message to std::cout with level DEBUG (lvl 10) on this logger. |
| Args | pack of Variadic arguments |
| args | args to be printed Get the current level of this logger |
|
inline |
Get the current counter of custom log calls
|
inline |
Get the current counter of debug calls
|
inline |
Get the current counter of error calls
|
inline |
Get the current counter of info calls
|
inline |
Get the current counter of warning calls
| void sevnstd::SevnLogging::info | ( | std::string | errstate, |
| const char * | file_input = nullptr, |
||
| int | line_input = -1 |
||
| ) | const |
Logs a message to std::cout with level INFO (lvl 20) on this logger.
| errstate | message to log. |
| file_input | Null or FILE. if FILE is used the message logs the name of the file where the log is called. |
| line_input | Null or LINE. if LINE is used the message logs the row number in the file where the log is called. |
| void sevnstd::SevnLogging::log | ( | int | level, |
| std::string | errstate, | ||
| const char * | file_input = nullptr, |
||
| int | line_input = -1, |
||
| int | stop = 0 |
||
| ) | const |
Logs a message to std::cout with integer level on this logger.
| level | message level. |
| errstate | message to log. |
| file_input | Null or FILE. if FILE is used the message logs the name of the file where the log is called. |
| line_input | Null or LINE. if LINE is used the message logs the row number in the file where the log is called. |
| stop | if != 0, throw a runtime exception. |
|
inline |
Variadic prints.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inlineprotected |
Set the static log_level.
| level |
| void sevnstd::SevnLogging::set_level | ( | std::string | level | ) |
Public interface to change log level
| level | string, can be: dubug, info, warning,error. |
| void sevnstd::SevnLogging::warning | ( | std::string | errstate, |
| const char * | file_input = nullptr, |
||
| int | line_input = -1 |
||
| ) | const |
Logs a message with std::cerr level WARNING (lvl 30) on this logger.
| errstate | message to log. |
| file_input | Null or FILE. if FILE is used the message logs the name of the file where the log is called. |
| line_input | Null or LINE. if LINE is used the message logs the row number in the file where the log is called. |
|
staticprotected |
Counter storing how many times a custom log has been called
|
staticprotected |
Counter storing how many times a debug log has been called
|
staticprotected |
Counter storing how many times an error log has been called
|
staticprotected |
Counter storing how many times a info log has been called
|
staticprotected |
Counter storing how many times a warning log has been called
|
staticprotected |
Current log level