#include #include namespace Void::Logging { namespace { thread_local std::vector> 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> fields) { for (const auto& [k, v] : fields) { t_fields.emplace_back(k, v); } m_count = fields.size(); } FieldScope::FieldScope( std::vector> 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> current_fields() noexcept { return t_fields; } } // namespace Void::Logging