Skip to main content

LogEntry

Struct LogEntry 

Source
pub struct LogEntry<Id> { /* private fields */ }
Expand description

A structured item displayed by the log viewer.

message is appended directly to the level label so callers can preserve source formatting such as INFO[0005] ....

Implementations§

Source§

impl<Id> LogEntry<Id>

Source

pub fn new(id: Id, level: LogLevel, message: impl Into<String>) -> Self

Creates a log entry with a stable caller-provided identifier.

Examples found in repository?
examples/showcase/app.rs (lines 412-416)
408fn sample_log_entries() -> Vec<material::widget::log_viewer::LogEntry<u64>> {
409    use material::widget::log_viewer::{LogEntry, LogLevel};
410
411    vec![
412        LogEntry::new(
413            1,
414            LogLevel::Info,
415            "[0005] [354884390 0ms] inbound/tun[tun-in]: inbound redirect connection from 172.19.0.1:47892",
416        ),
417        LogEntry::new(
418            2,
419            LogLevel::Info,
420            "[0005] [354884390 0ms] inbound/tun[tun-in]: inbound connection to 81.69.216.240:443",
421        ),
422        LogEntry::new(
423            3,
424            LogLevel::Info,
425            "[0005] [354884390 0ms] router: found user id: 10404",
426        ),
427        LogEntry::new(
428            4,
429            LogLevel::Info,
430            "[0005] [354884390 6ms] outbound/direct[direct]: outbound connection to 81.69.216.240:443",
431        ),
432        LogEntry::new(
433            5,
434            LogLevel::Error,
435            "[0005] [953254993 5.0s] connection: open connection to 172.19.0.2:853 using outbound/direct[direct]: dial tcp 172.19.0.2:853: i/o timeout",
436        ),
437        LogEntry::new(
438            6,
439            LogLevel::Error,
440            "[0005] [2920815984 5.4s] connection: open connection to 172.19.0.2:853 using outbound/direct[direct]: dial tcp 172.19.0.2:853: i/o timeout",
441        ),
442        LogEntry::new(
443            7,
444            LogLevel::Warn,
445            "[0005] router: fallback route selected for user id: 10325",
446        ),
447        LogEntry::new(
448            8,
449            LogLevel::Debug,
450            "[0005] [83404445 0ms] inbound/tun[tun-in]: inbound packet connection from 172.19.0.1:55755",
451        ),
452        LogEntry::new(
453            9,
454            LogLevel::Info,
455            "[0005] [83404445 0ms] inbound/tun[tun-in]: inbound packet connection to 198.18.0.16:443",
456        ),
457        LogEntry::new(
458            10,
459            LogLevel::Trace,
460            "[0005] [83404445 0ms] router: matching route rules",
461        ),
462        LogEntry::new(
463            11,
464            LogLevel::Trace,
465            "[0005] [83404445 0ms] router: rule[3] domain_suffix=.example.com did not match",
466        ),
467        LogEntry::new(
468            12,
469            LogLevel::Debug,
470            "[0005] [83404445 1ms] router: rule[7] ip_cidr=198.18.0.0/15 matched outbound/proxy[edge]",
471        ),
472        LogEntry::new(
473            13,
474            LogLevel::Info,
475            "[0005] [83404445 1ms] outbound/proxy[edge]: dialing 198.18.0.16:443 through 203.0.113.8:8443",
476        ),
477        LogEntry::new(
478            14,
479            LogLevel::Debug,
480            "[0006] dns: query A api.example.com from 172.19.0.1:53044",
481        ),
482        LogEntry::new(
483            15,
484            LogLevel::Trace,
485            "[0006] dns: cache miss for api.example.com IN A",
486        ),
487        LogEntry::new(
488            16,
489            LogLevel::Info,
490            "[0006] dns/doh[remote]: exchange query with https://dns.example/dns-query",
491        ),
492        LogEntry::new(
493            17,
494            LogLevel::Info,
495            "[0006] dns: resolved api.example.com to 198.51.100.42 ttl=300",
496        ),
497        LogEntry::new(
498            18,
499            LogLevel::Debug,
500            "[0005] [83404445 42ms] outbound/proxy[edge]: tunnel established with cipher aes-256-gcm",
501        ),
502        LogEntry::new(
503            19,
504            LogLevel::Info,
505            "[0005] [83404445 43ms] connection: connected to 198.18.0.16:443",
506        ),
507        LogEntry::new(
508            20,
509            LogLevel::Trace,
510            "[0005] [83404445 44ms] connection: uploaded 517 bytes, downloaded 1.8 KiB",
511        ),
512        LogEntry::new(
513            21,
514            LogLevel::Warn,
515            "[0007] inbound/tun[tun-in]: TCP handshake from 172.19.0.1:49102 exceeded 750ms",
516        ),
517        LogEntry::new(
518            22,
519            LogLevel::Info,
520            "[0007] [1653028021 811ms] inbound/tun[tun-in]: inbound connection to 192.0.2.80:80",
521        ),
522        LogEntry::new(
523            23,
524            LogLevel::Debug,
525            "[0007] [1653028021 812ms] router: protocol=http host=updates.example.com method=GET",
526        ),
527        LogEntry::new(
528            24,
529            LogLevel::Info,
530            "[0007] [1653028021 814ms] outbound/direct[direct]: outbound connection to 192.0.2.80:80",
531        ),
532        LogEntry::new(
533            25,
534            LogLevel::Warn,
535            "[0008] inbound/tun[tun-in]: dropped malformed UDP packet from 172.19.0.1:60418",
536        ),
537        LogEntry::new(
538            26,
539            LogLevel::Error,
540            "[0009] outbound/proxy[edge]: authentication failed for 203.0.113.8:8443: invalid server response",
541        ),
542        LogEntry::new(
543            27,
544            LogLevel::Info,
545            "[0009] outbound/proxy[edge]: retrying with secondary endpoint 203.0.113.9:8443",
546        ),
547        LogEntry::new(
548            28,
549            LogLevel::Debug,
550            "[0009] outbound/proxy[edge]: secondary endpoint connected in 68ms",
551        ),
552        LogEntry::new(
553            29,
554            LogLevel::Info,
555            "[0009] connection: traffic recovered after 1 retry",
556        ),
557        LogEntry::new(
558            30,
559            LogLevel::Trace,
560            "[0000] stats: connections=12 upload=4.2 MiB download=38.7 MiB memory=24.6 MiB goroutines=31",
561        ),
562    ]
563}
Source

pub const fn id(&self) -> &Id

Returns the stable identifier used for selection.

Source

pub const fn level(&self) -> LogLevel

Returns the log severity.

Source

pub fn message(&self) -> &str

Returns the source-formatted text following the severity label.

Source

pub fn line(&self) -> &str

Returns the complete line shown by the viewer and written on copy.

Trait Implementations§

Source§

impl<Id: Clone> Clone for LogEntry<Id>

Source§

fn clone(&self) -> LogEntry<Id>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<Id: Debug> Debug for LogEntry<Id>

Source§

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

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

impl<Id: Eq> Eq for LogEntry<Id>

Source§

impl<Id: PartialEq> PartialEq for LogEntry<Id>

Source§

fn eq(&self, other: &LogEntry<Id>) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl<Id: PartialEq> StructuralPartialEq for LogEntry<Id>

Auto Trait Implementations§

§

impl<Id> Freeze for LogEntry<Id>
where Id: Freeze,

§

impl<Id> RefUnwindSafe for LogEntry<Id>
where Id: RefUnwindSafe,

§

impl<Id> Send for LogEntry<Id>
where Id: Send,

§

impl<Id> Sync for LogEntry<Id>
where Id: Sync,

§

impl<Id> Unpin for LogEntry<Id>
where Id: Unpin,

§

impl<Id> UnsafeUnpin for LogEntry<Id>
where Id: UnsafeUnpin,

§

impl<Id> UnwindSafe for LogEntry<Id>
where Id: UnwindSafe,

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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<State, Message> IntoBoot<State, Message> for State

Source§

fn into_boot(self) -> (State, Task<Message>)

Turns some type into the initial state of some Application.
Source§

impl<T> MaybeClone for T

Source§

impl<T> MaybeDebug for T

Source§

impl<T> MaybeSend for T
where T: Send,

Source§

impl<T> MaybeSync for T
where T: Sync,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more