A round of new universal capabilities (all generic — templated/reflection based, no app coupling), verified by the test suite (1103 passing): Data reflection: - Reflect.hpp now (de)serializes chrono::duration, chrono::time_point, std::variant (tagged), std::array, and non-string-keyed std::map; Meta.hpp gains is_time_point_v et al. Async: - EventBus gains Mode::Async (worker-thread dispatch + flush()). - ThreadPool gains a bounded queue, try_submit(), and rejection stats. New modules / containers: - Resilience: TokenBucket, KeyedRateLimiter<Key>, CircuitBreaker, ResourceMonitor. - Containers: BufferPool<T> (size-class buffer reuse) and Cache<K,V> (per-entry TTL, LRU/LFU/FIFO eviction, hit/miss stats). - System: process/CPU/memory metrics (Metrics.hpp) and a streaming Process API. Plus FSM v2 (typed Success/Failure, sub-machines, parallel regions, history states, deferred events), Configuration/Logging reflection helpers, and the accompanying test suites. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
60 lines
1.2 KiB
C++
60 lines
1.2 KiB
C++
#include <Void/Log/Field.hpp>
|
|
|
|
#include <utility>
|
|
|
|
namespace Void::Logging
|
|
{
|
|
|
|
namespace
|
|
{
|
|
thread_local std::vector<std::pair<std::string, std::string>> t_fields;
|
|
} // namespace
|
|
|
|
FieldScope::FieldScope(std::string key, std::string value)
|
|
{
|
|
t_fields.emplace_back(std::move(key), std::move(value));
|
|
m_count = 1;
|
|
}
|
|
|
|
FieldScope::FieldScope(
|
|
std::initializer_list<std::pair<std::string, std::string>> fields)
|
|
{
|
|
for (const auto& [k, v] : fields) {
|
|
t_fields.emplace_back(k, v);
|
|
}
|
|
m_count = fields.size();
|
|
}
|
|
|
|
FieldScope::FieldScope(
|
|
std::vector<std::pair<std::string, std::string>> fields)
|
|
{
|
|
m_count = fields.size();
|
|
for (auto& [k, v] : fields) {
|
|
t_fields.emplace_back(std::move(k), std::move(v));
|
|
}
|
|
}
|
|
|
|
FieldScope::~FieldScope() noexcept
|
|
{
|
|
if (!m_active) {
|
|
return;
|
|
}
|
|
for (std::size_t i = 0; i < m_count && !t_fields.empty(); ++i) {
|
|
t_fields.pop_back();
|
|
}
|
|
}
|
|
|
|
FieldScope::FieldScope(FieldScope&& other) noexcept
|
|
: m_count(other.m_count), m_active(other.m_active)
|
|
{
|
|
other.m_active = false;
|
|
}
|
|
|
|
std::span<const std::pair<std::string, std::string>>
|
|
current_fields() noexcept
|
|
{
|
|
return t_fields;
|
|
}
|
|
|
|
} // namespace Void::Logging
|