aboutsummaryrefslogtreecommitdiff
path: root/extension/src/openvic2/Logger.cpp
diff options
context:
space:
mode:
author Hop311 <hop3114@gmail.com>2023-04-23 20:49:01 +0200
committer Hop311 <hop3114@gmail.com>2023-04-23 20:49:01 +0200
commitd3f3187209cb4085f27f95ce8ad2a77af25704fd (patch)
tree60971db586e78761341f2b48110d149b1ba0db9d /extension/src/openvic2/Logger.cpp
parent1084a5d64df5d3465ef90b3b85fe3374636a3fe8 (diff)
C++ refactoring + simulation prototype
Diffstat (limited to 'extension/src/openvic2/Logger.cpp')
-rw-r--r--extension/src/openvic2/Logger.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/extension/src/openvic2/Logger.cpp b/extension/src/openvic2/Logger.cpp
new file mode 100644
index 0000000..f211e7e
--- /dev/null
+++ b/extension/src/openvic2/Logger.cpp
@@ -0,0 +1,26 @@
+#include "openvic2/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; };
+
+const char* Logger::get_filename(const char* filepath) {
+ if (filepath == nullptr) return nullptr;
+ const char *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;
+}