AtilaCalculatorSoftware
2.3.4
C++ Interface for Atila fem resources files
|
Logging interface that stores logs, allow logfile writing, also contains other output methods. More...
#include <logger.h>
Public Member Functions | |
Logger (const Logger &logger) | |
Copy constructor of Logger. More... | |
~Logger () | |
Logger destructor. More... | |
Logger & | operator= (const Logger &logger) |
Copy operator of Logger. More... | |
size_t | log (const std::string &message, LogLevel level=Debug, time_t timestamp=time(nullptr)) |
Add a log entry in the current logger, automatically create log meta data. More... | |
Static Public Member Functions | |
static std::string | getEncodedLogLevel (LogLevel level) |
Get the string format of a given logging level. More... | |
static std::string | formatInt (const int &value, int size) |
Format integer value to string fitting a given size. More... | |
static std::string | formatEncodedLogLevel (const std::string &str, LogLevel level) |
Replace the level% variable by the given logging level. More... | |
static std::string | formatTime (std::string str, time_t timestamp, tm *t) |
static std::string | format (LogMetaData metaData, const std::string &message, const std::string &format=Logger::getLoggingFormat()) |
Get the formatted string of a log entry. More... | |
static Logger * | getInstance () |
Retrieve the current instance of logger or create a new one. More... | |
static LogEntries * | getLogs () |
Get the log entries. More... | |
static std::string | getLoggingFormat () |
static std::string | getDefaultLoggingFormat () |
static void | setVerbosity (bool verbosity) |
Enable or disable Logger verbosity. More... | |
static void | setVerboseLevel (LogLevel level) |
Set the verbosity level, will show all logs above the given level (including itself) More... | |
static void | setVerboseLevelRange (LogLevel lowest, LogLevel highest) |
Set the verbosity level range, won't show any log out of this range. More... | |
static void | setVerboseLevels (std::set< LogLevel > levels) |
Set the verbose levels manually, will only show elements that have the LogLevel in the set. More... | |
static void | logToFile (const std::string &filename, bool legacy=true) |
Writes incoming logs to the given file. More... | |
static void | setFileLogging (bool value) |
If set on true will enable file logging. More... | |
static void | setLoggingFormat (std::string format) |
Set the logging formatting string of the logger. More... | |
static size_t | trace_s (const std::string &message) |
Log a TRACE entry from the given string into the logger. More... | |
template<typename... TArgs> | |
static size_t | trace (TArgs const &... args) |
Concatenate and log the given elements as an TRACE entry. More... | |
static size_t | debug_s (const std::string &message) |
Log a DEBUG entry from the given string into the logger. More... | |
template<typename... TArgs> | |
static size_t | debug (TArgs const &... args) |
Concatenate and log the given elements as an DEBUG entry. More... | |
static size_t | info_s (const std::string &message) |
Log an INFO entry from the given string into the logger. More... | |
template<typename... TArgs> | |
static size_t | info (TArgs const &... args) |
Concatenate and log the given elements as an INFO entry. More... | |
static size_t | warn_s (const std::string &message) |
Log a WARN entry from the given string into the logger. More... | |
template<typename... TArgs> | |
static size_t | warn (TArgs const &... args) |
Concatenate and log the given elements as an WARN entry. More... | |
static size_t | error_s (const std::string &message) |
Log an ERROR entry from the given string into the logger. More... | |
template<typename... TArgs> | |
static size_t | error (TArgs const &... args) |
Concatenate and log the given elements as an ERROR entry. More... | |
static size_t | fatal_s (const std::string &message) |
Log a FATAL entry from the given string into the logger. More... | |
template<typename... TArgs> | |
static size_t | fatal (TArgs const &... args) |
Concatenate and log the given elements as an FATAL entry. More... | |
static size_t | addEntryListener (entry_listener listener) |
Add an entry listener in the entry listeners vector. More... | |
Private Member Functions | |
Logger () | |
Logger Singleton private constructor. More... | |
Private Attributes | |
LogEntries * | entries |
Nonformatted raw log entries. More... | |
bool | verbose |
If set on true, will show log messages in console. More... | |
std::set< LogLevel > | verbosityLevels |
Allowed logging levels on verbose (in console) More... | |
bool | fileLogging |
If set on true, will write log messages into file. More... | |
std::ofstream | loggingFile |
Output file stream for file writing log messages. More... | |
std::vector< entry_listener > | listeners |
List of listeners that will trigger on new entry. More... | |
Static Private Attributes | |
static LogTimeMode | timeMode = TimeLocal |
Time mode of the log entries (Local or UTC - absolute) Default value is TimeLocal. More... | |
static std::string | logFormat |
Current log formatting string, if empty will use defaultLogFormat. More... | |
static std::string | defaultLogFormat |
Default log formatting string. More... | |
static Logger * | instance = nullptr |
Logger instance. More... | |
Logging interface that stores logs, allow logfile writing, also contains other output methods.
Logger::Logger | ( | const Logger & | logger | ) |
Logger::~Logger | ( | ) |
Logger destructor.
|
private |
Logger Singleton private constructor.
|
static |
Add an entry listener in the entry listeners vector.
listener | Listener that will trigger on any new entry |
|
inlinestatic |
Concatenate and log the given elements as an DEBUG entry.
TArgs | Types of the given elements |
args | Elements to log (string, int, float, ...), will be concatenate |
|
static |
Log a DEBUG entry from the given string into the logger.
message | Message to log |
|
inlinestatic |
Concatenate and log the given elements as an ERROR entry.
TArgs | Types of the given elements |
args | Elements to log (string, int, float, ...), will be concatenate |
|
static |
Log an ERROR entry from the given string into the logger.
message | Message to log |
|
inlinestatic |
Concatenate and log the given elements as an FATAL entry.
TArgs | Types of the given elements |
args | Elements to log (string, int, float, ...), will be concatenate |
|
static |
Log a FATAL entry from the given string into the logger.
message | Message to log |
|
static |
Get the formatted string of a log entry.
metaData | Meta data of the log entry |
message | Message of the log entry |
format | The format to apply to the log entry |
|
static |
Replace the level% variable by the given logging level.
str | The base string |
level | The logging level |
|
static |
Format integer value to string fitting a given size.
value | Integer value to format |
size | Size of the string |
|
static |
the dt:x% variables by the given time values
str | The base string |
t | The time values |
|
static |
|
static |
Get the string format of a given logging level.
level | The logging level |
|
static |
Retrieve the current instance of logger or create a new one.
|
static |
|
static |
Get the log entries.
|
inlinestatic |
Concatenate and log the given elements as an INFO entry.
TArgs | Types of the given elements |
args | Elements to log (string, int, float, ...), will be concatenate |
|
static |
Log an INFO entry from the given string into the logger.
message | Message to log |
size_t Logger::log | ( | const std::string & | message, |
LogLevel | level = Debug , |
||
time_t | timestamp = time(nullptr) |
||
) |
Add a log entry in the current logger, automatically create log meta data.
message | Message to log |
level | Logging level (default = Debug) |
timestamp | Logging timestamp |
|
static |
Writes incoming logs to the given file.
filename | Path to the log file |
legacy | If set on true, will write all previous logs |
|
static |
If set on true will enable file logging.
|
static |
Set the logging formatting string of the logger.
format | Format of the log entries |
|
static |
Set the verbosity level, will show all logs above the given level (including itself)
level | Lower level of verbosity |
Set the verbosity level range, won't show any log out of this range.
lowest | Lowest verbosity level of the range |
highest | Highest verbosity level of the range |
|
static |
Set the verbose levels manually, will only show elements that have the LogLevel in the set.
levels | Set of allowed logging levels in verbose |
|
static |
Enable or disable Logger verbosity.
|
inlinestatic |
Concatenate and log the given elements as an TRACE entry.
TArgs | Types of the given elements |
args | Elements to log (string, int, float, ...), will be concatenate |
|
static |
Log a TRACE entry from the given string into the logger.
message | Message to log |
|
inlinestatic |
Concatenate and log the given elements as an WARN entry.
TArgs | Types of the given elements |
args | Elements to log (string, int, float, ...), will be concatenate |
|
static |
Log a WARN entry from the given string into the logger.
message | Message to log |
|
staticprivate |
Default log formatting string.
|
private |
Nonformatted raw log entries.
|
private |
If set on true, will write log messages into file.
|
private |
List of listeners that will trigger on new entry.
|
staticprivate |
Current log formatting string, if empty will use defaultLogFormat.
Variables:
All dt variables are related to the ctime library tm structure
Default value is an empty string
|
private |
Output file stream for file writing log messages.
|
staticprivate |
Time mode of the log entries (Local or UTC - absolute) Default value is TimeLocal.
|
private |
If set on true, will show log messages in console.
|
private |
Allowed logging levels on verbose (in console)