Enum session_log::Context

source ·
pub enum Context {
    Header {
        time: Time,
        source: Source,
        location: Location,
    },
    Footer {
        time: Time,
        source: Source,
        location: Location,
        elapsed: Duration,
    },
    Message {
        time: Time,
        source: Source,
        location: Location,
        level: Level,
        message: String,
    },
}
Expand description

Context type is presenting one line of logging with their corresponding information. It has three variants: Header, Footer, and Message. Header and Footer are used to represent the start and end of the logging session, while Message is used to represent the actual logging message. This type cannot be created outside of the library.

Variants§

§

Header

Fields

§time: Time
§source: Source
§location: Location
§

Footer

Fields

§time: Time
§source: Source
§location: Location
§elapsed: Duration
§

Message

Fields

§time: Time
§source: Source
§location: Location
§level: Level
§message: String

Implementations§

source§

impl Context

source

pub fn time(&self) -> &Time

Get the time of the context.

source

pub fn source(&self) -> &Source

Get the source of the context.

source

pub fn location(&self) -> &Location

Get the location of the context.

source

pub fn level(&self) -> Option<Level>

Get the level of the context. (Only available for Message variant)

source

pub fn message(&self) -> Option<&str>

Get the message of the context. (Only available for Message variant)

source

pub fn start(&self) -> Option<&Time>

Get the start time of the context. (Only available for Header variant)

source

pub fn elapsed(&self) -> Option<Duration>

Get the elapsed time of the context. (Only available for Footer variant)

source

pub fn is_header(&self) -> bool

Check if the context is a header.

Check if the context is a footer.

source

pub fn is_message(&self) -> bool

Check if the context is a message.

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