aboutsummaryrefslogtreecommitdiff
path: root/src/openvic/Logger.cpp
diff options
context:
space:
mode:
author Hop311 <Hop3114@gmail.com>2023-05-16 21:25:14 +0200
committer GitHub <noreply@github.com>2023-05-16 21:25:14 +0200
commitcedac2d020ae7e54d8fc5c21e390a306050bc220 (patch)
tree440634772615531e704a5554aa59c9890cd9cd85 /src/openvic/Logger.cpp
parent339e0278a2064f7eeb152fe8c5778840b609e9f3 (diff)
parent42d9d1d5417deb5979a9d5775cfe97dcff4b77ba (diff)
Merge pull request #3 from OpenVicProject/openvic-rename
Changed from OpenVic2 to OpenVic
Diffstat (limited to 'src/openvic/Logger.cpp')
-rw-r--r--src/openvic/Logger.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/openvic/Logger.cpp b/src/openvic/Logger.cpp
new file mode 100644
index 0000000..f93b8f1
--- /dev/null
+++ b/src/openvic/Logger.cpp
@@ -0,0 +1,26 @@
+#include "Logger.hpp"
+
+#include <iostream>
+
+using namespace OpenVic;
+
+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;
+}