Skip to main content

LogBar

Struct LogBar 

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

An expandable log bar anchored to the bottom of the viewport.

Owns its own entry buffer — construct once, store on your app struct, call LogBar::push (or one of the shortcuts) from any event handler, and call LogBar::show once per frame to render.

Implementations§

Source§

impl LogBar

Source

pub fn new() -> Self

Create a log bar with default settings: capacity 100, heading "Message Log", starts collapsed.

Source

pub fn heading(self, heading: impl Into<String>) -> Self

Set the label shown in the collapsed header. Default: "Message Log".

Source

pub fn max_entries(self, n: usize) -> Self

Set the maximum number of entries kept. When the buffer is full the oldest entry is dropped on each push. Default: 100. Clamped to a minimum of 1.

Source

pub fn id_salt(self, salt: impl Hash) -> Self

Override the id used for the panel and collapse state. Set this if you want more than one LogBar in a single app.

Source

pub fn push(&mut self, kind: LogKind, msg: impl Into<String>)

Append an entry. The current wall-clock time (HH:MM:SS UTC) is recorded as the row’s timestamp.

Source

pub fn sys(&mut self, msg: impl Into<String>)

Shortcut for push(LogKind::Sys, msg).

Source

pub fn out(&mut self, msg: impl Into<String>)

Shortcut for push(LogKind::Out, msg).

Source

pub fn recv(&mut self, msg: impl Into<String>)

Shortcut for push(LogKind::In, msg) — named recv because in is a Rust keyword.

Source

pub fn err(&mut self, msg: impl Into<String>)

Shortcut for push(LogKind::Err, msg).

Source

pub fn clear(&mut self)

Remove all entries.

Source

pub fn len(&self) -> usize

Number of entries currently stored.

Source

pub fn is_empty(&self) -> bool

Whether the buffer is empty.

Source

pub fn is_open(&self) -> bool

Whether the bar is currently expanded.

Source

pub fn set_open(&mut self, open: bool)

Programmatically set the expanded state.

Source

pub fn entries(&self) -> impl Iterator<Item = &LogEntry>

Iterate entries from newest to oldest.

Source

pub fn show(&mut self, ui: &mut Ui)

Render the bar. Call once per frame, before your CentralPanel, inside your App::ui method.

Trait Implementations§

Source§

impl Debug for LogBar

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for LogBar

Source§

fn default() -> Self

Returns the “default value” for a type. 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, S> SimdFrom<T, S> for T
where S: Simd,

Source§

fn simd_from(value: T, _simd: S) -> T

Source§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

Source§

fn simd_into(self, simd: S) -> T

Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.