diff options
Diffstat (limited to 'src/openvic-simulation/utility')
-rw-r--r-- | src/openvic-simulation/utility/Logger.cpp | 6 | ||||
-rw-r--r-- | src/openvic-simulation/utility/Logger.hpp | 31 |
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) |