#pragma once #include #include #include #include #include #include #include namespace Void::Logging { /// Distinguishes regular messages from scope boundary markers. /// /// Sinks may use Kind to render scope entries differently — /// e.g. with indentation, brackets, or a dedicated colour. /// /// Message — a regular log record /// ScopeEnter — emitted when a named scope opens (scope() call) /// ScopeExit — emitted when a named scope closes (RAII destructor) enum class Kind { Message, ScopeEnter, ScopeExit }; /// A single, immutable log record produced by Logger and handed to /// write() / on_flush(). All fields are populated by Logger before /// dispatch; derived sinks treat Entry as read-only. struct Entry { Kind kind{Kind::Message}; Level level{Level::Debug}; /// Human-readable text. For ScopeEnter/ScopeExit entries this /// is the scope name. std::string message{}; /// Wall-clock time at the moment log() / scope() was called. std::chrono::system_clock::time_point timestamp{ std::chrono::system_clock::now()}; /// Caller site captured automatically via /// std::source_location::current(). std::source_location location{}; /// OS thread that produced this entry. std::thread::id thread_id{std::this_thread::get_id()}; /// Frozen snapshot of the thread-local ScopedContext stack at log /// time. Ordered outermost → innermost (index 0 is the root /// scope). For ScopeEnter this already includes the new scope as /// the last element; for ScopeExit it reflects the stack *before* /// the pop. std::vector scopes{}; /// Structured key/value fields attached to this entry — a frozen /// snapshot of the thread-local FieldScope stack at log time. /// Formatters expose them as custom pattern tokens /// (`{field:key}`) and in JSON/logfmt output. Later duplicate /// keys win. std::vector> fields{}; }; } // namespace Void::Logging