diff options
Diffstat (limited to 'src/openvic-simulation/utility')
-rw-r--r-- | src/openvic-simulation/utility/Logger.hpp | 6 | ||||
-rw-r--r-- | src/openvic-simulation/utility/StringUtils.hpp | 3 |
2 files changed, 8 insertions, 1 deletions
diff --git a/src/openvic-simulation/utility/Logger.hpp b/src/openvic-simulation/utility/Logger.hpp index 20c7fdd..53decb3 100644 --- a/src/openvic-simulation/utility/Logger.hpp +++ b/src/openvic-simulation/utility/Logger.hpp @@ -72,6 +72,7 @@ namespace OpenVic { struct log_channel_t { log_func_t func; log_queue_t queue; + size_t message_count; }; template<typename... Ts> @@ -90,6 +91,8 @@ namespace OpenVic { do { log_channel.func(std::move(log_channel.queue.front())); log_channel.queue.pop(); + /* Only count printed messages, so that message_count matches what is seen in the console. */ + log_channel.message_count++; } while (!log_channel.queue.empty()); } } @@ -103,6 +106,9 @@ public: \ static inline void set_##name##_func(log_func_t log_func) { \ name##_channel.func = log_func; \ } \ + static inline size_t get_##name##_count() { \ + return name##_channel.message_count; \ + } \ template<typename... Ts> \ struct name { \ name(Ts&&... ts, source_location const& location = source_location::current()) { \ diff --git a/src/openvic-simulation/utility/StringUtils.hpp b/src/openvic-simulation/utility/StringUtils.hpp index c5a0b71..570f296 100644 --- a/src/openvic-simulation/utility/StringUtils.hpp +++ b/src/openvic-simulation/utility/StringUtils.hpp @@ -1,10 +1,11 @@ #pragma once +#include <algorithm> #include <cctype> -#include <cstdint> #include <cstring> #include <limits> #include <string_view> +#include <type_traits> namespace OpenVic::StringUtils { /* The constexpr function 'string_to_uint64' will convert a string into a uint64_t integer value. |