28 f.store(
true, std::memory_order_relaxed);
30 f.store(
true, std::memory_order_relaxed);
48 std::cout <<
"[MayaFlux::Journal] Initialized\n";
65 std::cout <<
"[MayaFlux::Journal] Shutdown\n";
79 while (
m_push_lock.test_and_set(std::memory_order_acquire))
89 std::string_view message, std::source_location location)
129 std::cout <<
"[MayaFlux::Journal] WARNING: Dropped "
130 << dropped <<
" log messages (buffer full)\n";
136 m_sinks.push_back(std::move(sink));
153 auto comp_idx =
static_cast<size_t>(comp);
162 auto ctx_idx =
static_cast<size_t>(ctx);
175 auto comp_idx =
static_cast<size_t>(component);
180 auto ctx_idx =
static_cast<size_t>(context);
188 if (colors_enabled) {
236 if (sink->is_available()) {
240 std::cout <<
"[MayaFlux::Journal] WARNING: sink threw during write, skipping\n";
253 using namespace std::chrono_literals;
256 std::this_thread::sleep_for(10ms);
285 : m_impl(
std::make_unique<
Impl>())
299 m_impl->drain_ring_buffer();
303 std::string_view message, std::source_location location)
310 std::string_view message, std::source_location location)
312 m_impl->scribe_rt(
severity, component, context, message, location);
316 std::string_view message)
324 m_impl->add_sink(std::move(sink));
334 m_impl->set_min_severity(min_sev);
339 m_impl->set_component_filter(comp, enabled);
344 m_impl->set_context_filter(ctx, enabled);
std::atomic_flag m_push_lock
std::array< std::atomic< bool >, magic_enum::enum_count< Component >()> m_component_filters
std::atomic< Severity > m_min_severity
std::atomic< bool > m_initialized
void set_component_filter(Component comp, bool enabled)
static constexpr size_t RT_RING_BUFFER_SIZE
bool should_log(Severity severity, Component component, Context context) const
std::array< std::atomic< bool >, magic_enum::enum_count< Context >()> m_context_filters
std::atomic< bool > m_shutdown_in_progress
std::atomic< bool > m_accepting_entries
void set_min_severity(Severity sev)
std::atomic< bool > m_worker_running
void write_to_sinks(const RealtimeEntry &entry)
Memory::MPSCQueue< RealtimeEntry, RT_RING_BUFFER_SIZE > m_rt_ring_buffer
static void write_to_console(const RealtimeEntry &entry)
Memory::LockFreeQueue< RealtimeEntry, RING_BUFFER_SIZE > m_ring_buffer
void scribe(const JournalEntry &entry)
void add_sink(std::unique_ptr< Sink > sink)
static constexpr size_t RING_BUFFER_SIZE
std::thread m_worker_thread
void set_context_filter(Context ctx, bool enabled)
void drain_ring_buffer()
Drain all pending ring buffer entries to sinks or console.
std::vector< std::unique_ptr< Sink > > m_sinks
std::atomic< uint64_t > m_dropped_messages
void scribe_rt(Severity severity, Component component, Context context, std::string_view message, std::source_location location)
void scribe_simple(Component component, Context context, std::string_view message)
Log a simple message without source location information.
void add_sink(std::unique_ptr< Sink > sink)
Add a log sink for output.
void scribe_rt(Severity severity, Component component, Context context, std::string_view message, std::source_location location=std::source_location::current())
Log a message from a real-time context with the specified severity, component, and context.
void clear_sinks()
Remove all sinks.
void set_component_filter(Component comp, bool enabled)
Enable or disable logging for a specific component.
void flush()
Synchronously drain all pending ring buffer entries to sinks.
static void shutdown()
Shutdown the logging system.
static Archivist & instance()
Get the singleton instance of the Archivist.
void set_min_severity(Severity min_sev)
Set the minimum severity level for logging.
void scribe(Severity severity, Component component, Context context, std::string_view message, std::source_location location=std::source_location::current())
Log a message with the specified severity, component, and context.
std::unique_ptr< Impl > m_impl
void set_context_filter(Context ctx, bool enabled)
Enable or disable logging for a specific context.
Singleton class responsible for managing log entries.
Policy-driven unified circular buffer implementation.
static constexpr std::string_view Yellow
static constexpr std::string_view BrightBlue
static constexpr std::string_view White
static constexpr std::string_view Blue
static constexpr std::string_view Reset
static constexpr std::string_view Green
static constexpr std::string_view Cyan
static constexpr std::string_view BrightRed
static bool initialize_console_colors()
static constexpr std::string_view Magenta
Context
Execution contexts for log messages.
constexpr std::string_view enum_to_string(EnumType value) noexcept
Universal enum to string converter using magic_enum (original case)
std::source_location location
A log entry structure to encapsulate log message details.
char message[MAX_MESSAGE_LENGTH]
Lightweight entry for lock-free ring buffer.