50 lines
1.4 KiB
C++
50 lines
1.4 KiB
C++
#pragma once
|
|
|
|
#include <Void/Log/Level.hpp>
|
|
|
|
#include <chrono>
|
|
#include <source_location>
|
|
#include <string>
|
|
#include <thread>
|
|
#include <utility>
|
|
#include <vector>
|
|
|
|
namespace Void::Logging
|
|
{
|
|
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.
|
|
std::vector<std::string> scopes{};
|
|
|
|
/// Structured key/value fields attached to this entry.
|
|
std::vector<std::pair<std::string, std::string>> fields{};
|
|
|
|
/// True when explicit oversize-truncation policy clipped message,
|
|
/// fields, scopes, or formatted payload.
|
|
bool truncated{false};
|
|
};
|
|
|
|
} // namespace Void::Logging
|