aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/utility
diff options
context:
space:
mode:
author hop311 <hop3114@gmail.com>2023-10-29 23:16:14 +0100
committer hop311 <hop3114@gmail.com>2023-11-07 19:32:43 +0100
commit8a00697a0e6a4168894594eadc373836a1689eea (patch)
treea8af4d6c77764644305be324b32b96b9c272e563 /src/openvic-simulation/utility
parent61e5c971cd371950a3bd659799208d8143dddd4f (diff)
Country: datatypes + TGC compat changes
Diffstat (limited to 'src/openvic-simulation/utility')
-rw-r--r--src/openvic-simulation/utility/Logger.cpp6
-rw-r--r--src/openvic-simulation/utility/Logger.hpp31
2 files changed, 19 insertions, 18 deletions
diff --git a/src/openvic-simulation/utility/Logger.cpp b/src/openvic-simulation/utility/Logger.cpp
index 5e25c98..63dfd6c 100644
--- a/src/openvic-simulation/utility/Logger.cpp
+++ b/src/openvic-simulation/utility/Logger.cpp
@@ -6,13 +6,13 @@ using namespace OpenVic;
void Logger::set_logger_funcs() {
Logger::set_info_func([](std::string&& str) {
- std::cout << str;
+ std::cout << "[INFO] " << str;
});
Logger::set_warning_func([](std::string&& str) {
- std::cerr << str;
+ std::cerr << "[WARNING] " << str;
});
Logger::set_error_func([](std::string&& str) {
- std::cerr << str;
+ std::cerr << "[ERROR] " << str;
});
}
diff --git a/src/openvic-simulation/utility/Logger.hpp b/src/openvic-simulation/utility/Logger.hpp
index a1c599d..04306f7 100644
--- a/src/openvic-simulation/utility/Logger.hpp
+++ b/src/openvic-simulation/utility/Logger.hpp
@@ -65,13 +65,13 @@ namespace OpenVic {
struct log {
log(log_channel_t& log_channel, Ts&&... ts, source_location const& location) {
std::stringstream stream;
- stream << "\n" << get_filename(location.file_name()) << "("
+ stream << get_filename(location.file_name()) << "("
/* Function name removed to reduce clutter. It is already included
* in Godot's print functions, so this was repeating it. */
//<< location.line() << ") `" << location.function_name() << "`: ";
<< location.line() << "): ";
((stream << std::forward<Ts>(ts)), ...);
- stream << std::endl;
+ stream << "\n" << std::endl;
log_channel.queue.push(stream.str());
if (log_channel.func) {
do {
@@ -83,20 +83,21 @@ namespace OpenVic {
};
#define LOG_FUNC(name) \
- private: \
- static inline log_channel_t name##_channel {}; \
- public: \
- static inline void set_##name##_func(log_func_t log_func) { \
- name##_channel.func = log_func; \
+private: \
+ static inline log_channel_t name##_channel {}; \
+\
+public: \
+ static inline void set_##name##_func(log_func_t log_func) { \
+ name##_channel.func = log_func; \
+ } \
+ template<typename... Ts> \
+ struct name { \
+ name(Ts&&... ts, source_location const& location = source_location::current()) { \
+ log<Ts...> { name##_channel, std::forward<Ts>(ts)..., location }; \
} \
- template<typename... Ts> \
- struct name { \
- name(Ts&&... ts, source_location const& location = source_location::current()) { \
- log<Ts...> { name##_channel, std::forward<Ts>(ts)..., location }; \
- } \
- }; \
- template<typename... Ts> \
- name(Ts&&...) -> name<Ts...>;
+ }; \
+ template<typename... Ts> \
+ name(Ts&&...) -> name<Ts...>;
LOG_FUNC(info)
LOG_FUNC(warning)