libnick 2024.12.0
A cross-platform base for native Nickvision applications.
|
A logger of application messages. More...
#include <logger.h>
Public Member Functions | |
Logger (LogLevel minimum=LogLevel::Debug) | |
Constructs a Logger. | |
Logger (const std::filesystem::path &path, LogLevel minimum=LogLevel::Debug, bool append=true) | |
Constructs a Logger. | |
const std::filesystem::path & | getPath () const |
Gets the path for the logs file. | |
void | log (LogLevel level, const std::string &message, const std::source_location &source=std::source_location::current()) const |
Logs a message. | |
A logger of application messages.
Nickvision::Logging::Logger::Logger | ( | LogLevel | minimum = LogLevel::Debug | ) |
Constructs a Logger.
All messages are printed to standard outputs.
minimum | The minimum supported LogLevel |
Nickvision::Logging::Logger::Logger | ( | const std::filesystem::path & | path, |
LogLevel | minimum = LogLevel::Debug, | ||
bool | append = true ) |
Constructs a Logger.
All messages are saved to the provided file and printed to standard outputs.
path | The path to the log file |
minimum | The minimum supported LogLevel |
append | Whether or not to append to the file if it already exists |
std::runtime_error | Thrown if the unable to open the file |
const std::filesystem::path & Nickvision::Logging::Logger::getPath | ( | ) | const |
Gets the path for the logs file.
If the logger has no file attached, an empty path will be returned.
void Nickvision::Logging::Logger::log | ( | LogLevel | level, |
const std::string & | message, | ||
const std::source_location & | source = std::source_location::current() ) const |
Logs a message.
level | LogLevel |
message | The message to log |
source | The code location of the log message |