diff options
author | hop311 <hop3114@gmail.com> | 2024-01-17 23:24:39 +0100 |
---|---|---|
committer | hop311 <hop3114@gmail.com> | 2024-01-18 23:29:40 +0100 |
commit | e33a330129364b4bd632b2fd531a996b8c57cefb (patch) | |
tree | 88365260addebee9d3ac798d484e02ab18f56692 /src/openvic-simulation/utility | |
parent | b5783116f67c9f7aa9d8d9653e6bda0227f67cd2 (diff) |
Parse missing variables, Logger counting, misc cleanup
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. |