Skip to main content

LockFreeEngine

Struct LockFreeEngine 

Source
pub struct LockFreeEngine { /* private fields */ }
Expand description

The near-lock-free ingestion engine.

Owns the ring buffer, flusher thread, and TUI metrics counters. Access the global instance via ENGINE.

Implementations§

Source§

impl LockFreeEngine

Source

pub fn new(capacity: usize) -> Self

Create a new engine with the given buffer capacity and spawn the flusher.

§Panics

Panics if the OS cannot spawn the background flusher thread.

Source

pub fn ingest(&self, event: LogEvent)

Appends an event to the ring buffer.

If the buffer is full, the oldest event is evicted to make room. Dropped events are tracked via TuiMetrics::dropped_events.

The event, level, error and format counters are updated as the flusher drains each event (or when one is dropped), so they trail ingest by at most one flush.

Source

pub fn set_filter(&self, level: u8)

Sets the global log level filter.

Source

pub fn filter_level(&self) -> u8

Returns the current global log level filter.

Source

pub fn inc_format(&self, format: LogFormat)

Increments the format counter in the TUI metrics.

The engine counts each event’s format itself as it drains it; call this only for records that bypass Self::ingest.

Source

pub fn inc_spans(&self)

Increments the active span count in the TUI metrics.

Source

pub fn dec_spans(&self)

Decrements the active span count in the TUI metrics.

Source

pub fn active_spans(&self) -> usize

Returns the current number of active spans.

Source

pub fn apply_config(&self, config: &Config)

Applies configuration settings to the engine.

Sets the log level filter from the config. File sink construction and rotation are handled by the flusher thread at startup via PlatformSink::from_config.

Source

pub fn shutdown(&self)

Safely halts the background thread, flushing pending logs.

Signals the flusher thread to stop and waits for it to finish draining any remaining events from the queue.

Trait Implementations§

Source§

impl Debug for LockFreeEngine

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.