diff options
author | ClarkeCode <clarke.john.robert@gmail.com> | 2023-05-01 02:48:35 +0200 |
---|---|---|
committer | ClarkeCode <clarke.john.robert@gmail.com> | 2023-05-01 02:48:35 +0200 |
commit | c92481448159d3a363d6a99b3025bd2358c3dab6 (patch) | |
tree | 3ee57808029036a7edab750f4454aeb6c50f3df3 /Logger.cpp |
Initial commit
Diffstat (limited to 'Logger.cpp')
-rw-r--r-- | Logger.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/Logger.cpp b/Logger.cpp new file mode 100644 index 0000000..4d7378e --- /dev/null +++ b/Logger.cpp @@ -0,0 +1,26 @@ +#include "Logger.hpp" + +#include <iostream> + +using namespace OpenVic2; + +Logger::log_func_t Logger::info_func = [](std::string&& str) { std::cout << str; }; +Logger::log_func_t Logger::error_func = [](std::string&& str) { std::cerr << str; }; + +char const* Logger::get_filename(char const* filepath) { + if (filepath == nullptr) return nullptr; + char const* last_slash = filepath; + while (*filepath != '\0') { + if (*filepath == '\\' || *filepath == '/') last_slash = filepath + 1; + filepath++; + } + return last_slash; +} + +void Logger::set_info_func(log_func_t log_func) { + info_func = log_func; +} + +void Logger::set_error_func(log_func_t log_func) { + error_func = log_func; +} |