From 8a00697a0e6a4168894594eadc373836a1689eea Mon Sep 17 00:00:00 2001 From: hop311 Date: Sun, 29 Oct 2023 22:16:14 +0000 Subject: Country: datatypes + TGC compat changes --- src/openvic-simulation/utility/Logger.cpp | 6 +++--- src/openvic-simulation/utility/Logger.hpp | 31 ++++++++++++++++--------------- 2 files changed, 19 insertions(+), 18 deletions(-) (limited to 'src/openvic-simulation/utility') 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)), ...); - 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 \ + struct name { \ + name(Ts&&... ts, source_location const& location = source_location::current()) { \ + log { name##_channel, std::forward(ts)..., location }; \ } \ - template \ - struct name { \ - name(Ts&&... ts, source_location const& location = source_location::current()) { \ - log { name##_channel, std::forward(ts)..., location }; \ - } \ - }; \ - template \ - name(Ts&&...) -> name; + }; \ + template \ + name(Ts&&...) -> name; LOG_FUNC(info) LOG_FUNC(warning) -- cgit v1.2.3-56-ga3b1