pub struct LogBuffer {
entries: Arc<Mutex<VecDeque<LogEntry>>>,
max_size: usize,
ui_sender: Arc<Mutex<Option<UnboundedSender<UIEvent>>>>,
current_display_level: Arc<Mutex<Level>>,
current_ui_mode: Arc<Mutex<UIMode>>,
pending_batch: Arc<Mutex<Vec<LogEntry>>>,
batch_timer: Arc<Mutex<Option<Interval>>>,
}Expand description
A buffer for storing and managing log entries.
Fields§
§entries: Arc<Mutex<VecDeque<LogEntry>>>The circular buffer of log entries.
max_size: usizeThe maximum number of entries to store in the buffer.
ui_sender: Arc<Mutex<Option<UnboundedSender<UIEvent>>>>The sender for sending UI events.
current_display_level: Arc<Mutex<Level>>The current log level to display in the UI.
current_ui_mode: Arc<Mutex<UIMode>>The current UI mode.
pending_batch: Arc<Mutex<Vec<LogEntry>>>A batch of pending log entries to be sent to the UI.
batch_timer: Arc<Mutex<Option<Interval>>>The timer for sending log batches.
Implementations§
Source§impl LogBuffer
impl LogBuffer
Sourcepub fn new(max_size: usize) -> Self
pub fn new(max_size: usize) -> Self
Creates a new LogBuffer.
§Arguments
max_size- The maximum number of entries to store in the buffer.
Sourcepub fn set_ui_sender(&self, sender: UnboundedSender<UIEvent>)
pub fn set_ui_sender(&self, sender: UnboundedSender<UIEvent>)
Sets the UI sender.
This is used to send events to the UI thread.
Sourcepub fn add_entry(&self, entry: LogEntry)
pub fn add_entry(&self, entry: LogEntry)
Adds a new log entry to the buffer.
The entry is always stored in the buffer, but it is only sent to the UI if its level is at or above the current display level.
Sourcepub fn set_display_level(&self, level: Level)
pub fn set_display_level(&self, level: Level)
Sets the current display level for filtering UI notifications.
Sourcepub fn set_ui_mode(&self, mode: UIMode)
pub fn set_ui_mode(&self, mode: UIMode)
Sets the current UI mode to optimize notifications.
Sourcefn start_batch_timer_if_needed(&self)
fn start_batch_timer_if_needed(&self)
Starts the batch timer if it’s not already running.
Auto Trait Implementations§
impl Freeze for LogBuffer
impl RefUnwindSafe for LogBuffer
impl Send for LogBuffer
impl Sync for LogBuffer
impl Unpin for LogBuffer
impl UnwindSafe for LogBuffer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more