29 auto start = std::chrono::steady_clock::now();
30 while (
m_worker_thread.joinable() && std::chrono::steady_clock::now() - start < std::chrono::milliseconds(500)) {
31 std::this_thread::sleep_for(std::chrono::milliseconds(10));
49 std::cout <<
"[MayaFlux::Journal] Initialized\n";
71 std::cout <<
"[MayaFlux::Journal] Shutdown\n";
80 auto comp_idx =
static_cast<size_t>(entry.
component);
105 RealtimeEntry entry(severity, component, context, message, location);
115 m_sinks.push_back(std::move(sink));
134 auto comp_idx =
static_cast<size_t>(comp);
150 auto comp_idx =
static_cast<size_t>(component);
208 std::cout <<
" (" << entry.
location.file_name()
276 if (sink->is_available()) {
285 if (sink->is_available()) {
309 using namespace std::chrono_literals;
315 std::this_thread::sleep_for(10ms);
338 std::cout <<
"[MayaFlux::Journal] WARNING: Dropped " << dropped
339 <<
" realtime log messages (buffer full)\n";
363 : m_impl(
std::make_unique<
Impl>())
376 std::string_view message, std::source_location location)
378 JournalEntry entry(severity, component, context, message, location);
383 std::string_view message, std::source_location location)
385 m_impl->scribe_rt(severity, component, context, message, location);
389 std::string_view message)
397 m_impl->add_sink(std::move(sink));
407 m_impl->set_min_severity(min_sev);
412 m_impl->set_component_filter(comp, enabled);
bool should_log(Severity severity, Component component) const
std::atomic< Severity > m_min_severity
void set_component_filter(Component comp, bool enabled)
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)
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
RingBuffer< RealtimeEntry, RING_BUFFER_SIZE > m_ring_buffer
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
Singleton class responsible for managing log entries.
Lock-free SPSC (Single Producer Single Consumer) ring buffer.
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.