31 auto start = std::chrono::steady_clock::now();
32 while (
m_worker_thread.joinable() && std::chrono::steady_clock::now() - start < std::chrono::milliseconds(500)) {
33 std::this_thread::sleep_for(std::chrono::milliseconds(10));
51 std::cout <<
"[MayaFlux::Journal] Initialized\n";
73 std::cout <<
"[MayaFlux::Journal] Shutdown\n";
106 m_sinks.push_back(std::move(sink));
125 auto comp_idx =
static_cast<size_t>(comp);
136 auto ctx_idx =
static_cast<size_t>(ctx);
152 auto comp_idx =
static_cast<size_t>(component);
157 auto ctx_idx =
static_cast<size_t>(context);
212 std::cout <<
" (" << entry.
location.file_name()
278 if (sink->is_available()) {
287 if (sink->is_available()) {
311 using namespace std::chrono_literals;
317 std::this_thread::sleep_for(10ms);
340 std::cout <<
"[MayaFlux::Journal] WARNING: Dropped " << dropped
341 <<
" realtime log messages (buffer full)\n";
366 : m_impl(
std::make_unique<
Impl>())
379 std::string_view message, std::source_location location)
386 std::string_view message, std::source_location location)
388 m_impl->scribe_rt(
severity, component, context, message, location);
392 std::string_view message)
400 m_impl->add_sink(std::move(sink));
410 m_impl->set_min_severity(min_sev);
415 m_impl->set_component_filter(comp, enabled);
420 m_impl->set_context_filter(ctx, enabled);
std::atomic< Severity > m_min_severity
void set_component_filter(Component comp, bool enabled)
bool should_log(Severity severity, Component component, Context context) const
std::atomic< bool > m_shutdown_in_progress
void set_min_severity(Severity sev)
std::atomic< bool > m_worker_running
void write_to_sinks(const RealtimeEntry &entry)
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
std::array< bool, magic_enum::enum_count< Component >()> m_component_filters
std::array< bool, magic_enum::enum_count< Context >()> m_context_filters
void set_context_filter(Context ctx, bool enabled)
static void write_to_console(const JournalEntry &entry)
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 write_to_sinks(const JournalEntry &entry)
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.
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.
static bool colors_enabled
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.