|
Hyperiso 1.0.3
Modular flavour-physics calculations, Wilson coefficients and statistical inference
|
A singleton logging utility supporting multiple logging levels and concurrent logging to file and terminal. More...
#include <Logger.h>
Public Types | |
| enum class | LogLevel { TRACE , VERBOSE , DEBUG , INFO , WARN , ERROR } |
| Logging levels supported by the Logger. More... | |
Public Member Functions | |
| void | setLevel (LogLevel level) |
| Sets the logging level. | |
| void | setLogDirectory (const std::string &directory, std::size_t maxSize=10048576) |
| Sets the directory for storing log files. | |
| void | setEnabled (bool enabled) |
| Enables or disables the Logger. | |
| std::string | getLogFilenameForThread (std::thread::id threadId) |
| Retrieves the log filename for the specified thread. | |
| std::string | getLogFilenameWithSuffix (const std::string &baseName, int suffix) |
| Retrieves a log filename with a suffix. | |
| template<typename... Args> | |
| void | log (LogLevel messageLevel, const char *file, int line, const char *func, const char *errorType, const Args &... args) noexcept(false) |
| Logs a message with the specified level and details. | |
| ~Logger () | |
| Destructor for Logger, ensures graceful shutdown of logging. | |
Static Public Member Functions | |
| static Logger * | getInstance () |
| Retrieves the singleton instance of the Logger. | |
Public Attributes | |
| std::thread::id | threadId |
A singleton logging utility supporting multiple logging levels and concurrent logging to file and terminal.
|
strong |
Logging levels supported by the Logger.
| Logger::~Logger | ( | ) |
Destructor for Logger, ensures graceful shutdown of logging.
Definition at line 25 of file Logger.cpp.
|
static |
Retrieves the singleton instance of the Logger.
Definition at line 5 of file Logger.cpp.
| std::string Logger::getLogFilenameForThread | ( | std::thread::id | threadId | ) |
Retrieves the log filename for the specified thread.
| threadId | The thread ID. |
Definition at line 80 of file Logger.cpp.
| std::string Logger::getLogFilenameWithSuffix | ( | const std::string & | baseName, |
| int | suffix | ||
| ) |
Retrieves a log filename with a suffix.
| baseName | Base name for the log file. |
| suffix | Integer suffix for the filename. |
Definition at line 74 of file Logger.cpp.
| void Logger::log | ( | LogLevel | messageLevel, |
| const char * | file, | ||
| int | line, | ||
| const char * | func, | ||
| const char * | errorType, | ||
| const Args &... | args | ||
| ) |
Logs a message with the specified level and details.
| messageLevel | The logging level of the message. |
| file | Source file where the log is made. |
| line | Line number in the source file. |
| func | Function name. |
| errorType | Optional error type string for error-level logs. |
| args | The message to log. |
| std::runtime_error | If logging to file fails. |
| void Logger::setEnabled | ( | bool | enabled | ) |
Enables or disables the Logger.
| enabled | Boolean flag to enable or disable logging. |
Definition at line 50 of file Logger.cpp.
| void Logger::setLevel | ( | LogLevel | level | ) |
Sets the logging level.
| level | The minimum logging level to be logged. |
Definition at line 38 of file Logger.cpp.
| void Logger::setLogDirectory | ( | const std::string & | directory, |
| std::size_t | maxSize = 10048576 |
||
| ) |
Sets the directory for storing log files.
| directory | Directory path where log files are stored. |
| maxSize | Maximum allowed size for each log file in bytes, default is 10048576. |
Definition at line 42 of file Logger.cpp.
| std::thread::id Logger::threadId |