pub struct LoggingHelper { /* private fields */ }Expand description
Centralized logging with rotating file handler and in-memory ring buffer.
Implementations§
Source§impl LoggingHelper
impl LoggingHelper
Sourcepub fn new(config: LoggingConfig) -> Result<Self>
pub fn new(config: LoggingConfig) -> Result<Self>
Create a new LoggingHelper and set up logging infrastructure.
Sourcepub fn install(config: LoggingConfig) -> Result<Arc<LoggingHelper>>
pub fn install(config: LoggingConfig) -> Result<Arc<LoggingHelper>>
Build a LoggingHelper from config and install it as the global log
backend (log::set_boxed_logger + set_max_level). Returns the shared
handle; keep it alive for ring-buffer/file access. After this call every
log::info!/warn!/error! in the process is routed to the file, the
ring buffer and — unless disabled — the console.
Fails if a global logger was already installed (the log crate permits
exactly one) or the log directory/file cannot be opened.
Sourcepub fn record(&self, record: &Record<'_>)
pub fn record(&self, record: &Record<'_>)
Format and write a single log record to the file, the ring buffer and
(when enabled) the console. Used by the log::Log adapter.
Sourcepub fn get_ring_buffer(&self) -> String
pub fn get_ring_buffer(&self) -> String
Get the ring buffer contents as a string.
Sourcepub fn ring_buffer(&self) -> &Arc<RingBuffer>
pub fn ring_buffer(&self) -> &Arc<RingBuffer>
Get a reference to the ring buffer for direct access.
Sourcepub fn write_line(&self, line: &str)
pub fn write_line(&self, line: &str)
Write a log line to both file and ring buffer.