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

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.
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