Unified logging service for Icarus.
More...
#include <LogService.hpp>
|
| using | Sink = std::function<void(const std::vector<LogEntry> &)> |
| | Sink callback type: receives batch of entries to output.
|
|
| | LogService ()=default |
| void | SetImmediateMode (bool immediate) |
| | Enable immediate flush after each log (for lifecycle phases).
|
| bool | IsImmediateMode () const |
| void | SetMinLevel (LogLevel level) |
| | Set minimum level (below this = dropped).
|
| LogLevel | GetMinLevel () const |
| void | Reserve (std::size_t capacity) |
| | Set buffer capacity (pre-allocate for performance).
|
| void | AddSink (Sink sink) |
| | Add an output sink.
|
| void | AddSink (Sink sink, LogLevel min_level) |
| | Add a sink that only receives entries at or above a level.
|
| void | ClearSinks () |
| | Clear all sinks.
|
| void | Log (LogLevel level, double sim_time, std::string_view message) |
| | Log a message (uses current thread-local context).
|
| void | Log (LogLevel level, double sim_time, std::string_view message, const LogContext &ctx) |
| | Log with explicit context (bypasses thread-local).
|
| void | Trace (double t, std::string_view msg) |
| void | Debug (double t, std::string_view msg) |
| void | Info (double t, std::string_view msg) |
| void | Event (double t, std::string_view msg) |
| void | Warning (double t, std::string_view msg) |
| void | Error (double t, std::string_view msg) |
| void | Fatal (double t, std::string_view msg) |
| void | Flush (bool sort_by_time=false) |
| | Flush buffer to all sinks.
|
| void | FlushAndClear (bool sort_by_time=false) |
| | Flush and clear buffer.
|
| void | Clear () |
| | Clear buffer without flushing (discard pending logs).
|
| std::size_t | PendingCount () const |
| bool | HasPending () const |
| std::vector< LogEntry > | GetPending () const |
| bool | HasErrors () const |
| | Check if any errors were logged (in buffer or flushed).
|
| bool | HasFatalErrors () const |
| std::size_t | ErrorCount () const |
| std::size_t | FatalCount () const |
| void | ResetErrorCounts () |
| | Reset error counts (call at start of new run).
|
| std::vector< LogEntry > | GetEntriesAtLevel (LogLevel level) const |
| std::vector< LogEntry > | GetEntriesForEntity (std::string_view entity) const |
| std::vector< LogEntry > | GetEntriesForComponent (std::string_view path) const |
Unified logging service for Icarus.
ALL logging goes through this service. It operates in two modes:
- Immediate mode (Provision/Stage/Shutdown): Logs are flushed to sinks immediately after each call. Use for lifecycle events where you want instant feedback.
- Buffered mode (Run/Step): Logs are collected into a buffer, flushed at end of step. Use during hot loop to eliminate I/O latency.
The Simulator controls the mode based on lifecycle phase.
◆ Sink
Sink callback type: receives batch of entries to output.
◆ LogService()
| icarus::LogService::LogService |
( |
| ) |
|
|
default |
◆ AddSink() [1/2]
| void icarus::LogService::AddSink |
( |
Sink | sink | ) |
|
|
inline |
◆ AddSink() [2/2]
| void icarus::LogService::AddSink |
( |
Sink | sink, |
|
|
LogLevel | min_level ) |
|
inline |
Add a sink that only receives entries at or above a level.
◆ Clear()
| void icarus::LogService::Clear |
( |
| ) |
|
|
inline |
Clear buffer without flushing (discard pending logs).
◆ ClearSinks()
| void icarus::LogService::ClearSinks |
( |
| ) |
|
|
inline |
◆ Debug()
| void icarus::LogService::Debug |
( |
double | t, |
|
|
std::string_view | msg ) |
|
inline |
◆ Error()
| void icarus::LogService::Error |
( |
double | t, |
|
|
std::string_view | msg ) |
|
inline |
◆ ErrorCount()
| std::size_t icarus::LogService::ErrorCount |
( |
| ) |
const |
|
inlinenodiscard |
◆ Event()
| void icarus::LogService::Event |
( |
double | t, |
|
|
std::string_view | msg ) |
|
inline |
◆ Fatal()
| void icarus::LogService::Fatal |
( |
double | t, |
|
|
std::string_view | msg ) |
|
inline |
◆ FatalCount()
| std::size_t icarus::LogService::FatalCount |
( |
| ) |
const |
|
inlinenodiscard |
◆ Flush()
| void icarus::LogService::Flush |
( |
bool | sort_by_time = false | ) |
|
|
inline |
Flush buffer to all sinks.
◆ FlushAndClear()
| void icarus::LogService::FlushAndClear |
( |
bool | sort_by_time = false | ) |
|
|
inline |
◆ GetEntriesAtLevel()
| std::vector< LogEntry > icarus::LogService::GetEntriesAtLevel |
( |
LogLevel | level | ) |
const |
|
inlinenodiscard |
◆ GetEntriesForComponent()
| std::vector< LogEntry > icarus::LogService::GetEntriesForComponent |
( |
std::string_view | path | ) |
const |
|
inlinenodiscard |
◆ GetEntriesForEntity()
| std::vector< LogEntry > icarus::LogService::GetEntriesForEntity |
( |
std::string_view | entity | ) |
const |
|
inlinenodiscard |
◆ GetMinLevel()
| LogLevel icarus::LogService::GetMinLevel |
( |
| ) |
const |
|
inlinenodiscard |
◆ GetPending()
| std::vector< LogEntry > icarus::LogService::GetPending |
( |
| ) |
const |
|
inlinenodiscard |
◆ HasErrors()
| bool icarus::LogService::HasErrors |
( |
| ) |
const |
|
inlinenodiscard |
Check if any errors were logged (in buffer or flushed).
◆ HasFatalErrors()
| bool icarus::LogService::HasFatalErrors |
( |
| ) |
const |
|
inlinenodiscard |
◆ HasPending()
| bool icarus::LogService::HasPending |
( |
| ) |
const |
|
inlinenodiscard |
◆ Info()
| void icarus::LogService::Info |
( |
double | t, |
|
|
std::string_view | msg ) |
|
inline |
◆ IsImmediateMode()
| bool icarus::LogService::IsImmediateMode |
( |
| ) |
const |
|
inlinenodiscard |
◆ Log() [1/2]
| void icarus::LogService::Log |
( |
LogLevel | level, |
|
|
double | sim_time, |
|
|
std::string_view | message ) |
|
inline |
Log a message (uses current thread-local context).
◆ Log() [2/2]
| void icarus::LogService::Log |
( |
LogLevel | level, |
|
|
double | sim_time, |
|
|
std::string_view | message, |
|
|
const LogContext & | ctx ) |
|
inline |
Log with explicit context (bypasses thread-local).
◆ PendingCount()
| std::size_t icarus::LogService::PendingCount |
( |
| ) |
const |
|
inlinenodiscard |
◆ Reserve()
| void icarus::LogService::Reserve |
( |
std::size_t | capacity | ) |
|
|
inline |
Set buffer capacity (pre-allocate for performance).
◆ ResetErrorCounts()
| void icarus::LogService::ResetErrorCounts |
( |
| ) |
|
|
inline |
Reset error counts (call at start of new run).
◆ SetImmediateMode()
| void icarus::LogService::SetImmediateMode |
( |
bool | immediate | ) |
|
|
inline |
Enable immediate flush after each log (for lifecycle phases).
◆ SetMinLevel()
| void icarus::LogService::SetMinLevel |
( |
LogLevel | level | ) |
|
|
inline |
Set minimum level (below this = dropped).
◆ Trace()
| void icarus::LogService::Trace |
( |
double | t, |
|
|
std::string_view | msg ) |
|
inline |
◆ Warning()
| void icarus::LogService::Warning |
( |
double | t, |
|
|
std::string_view | msg ) |
|
inline |
The documentation for this class was generated from the following file: