Enum session_log::Context

source ·
pub enum Context<'a> {
    Log {
        time: DateTime<Local>,
        level: Level,
        file: &'static str,
        line: u32,
        logger: &'a str,
        session: Option<&'a str>,
        message: &'a str,
    },
    SessionStart {
        time: DateTime<Local>,
        file: &'static str,
        line: u32,
        logger: &'a str,
        session: &'a str,
    },
    SessionEnd {
        time: DateTime<Local>,
        elapsed: i64,
        file: &'static str,
        line: u32,
        logger: &'a str,
        session: &'a str,
    },
}
Expand description

Context of each log message.

Variants§

§

Log

Regular log message. All log made by logger will have this context.

Fields

§level: Level
§file: &'static str
§line: u32
§logger: &'a str
§session: Option<&'a str>
§message: &'a str
§

SessionStart

Start of a session. Occurs when a logger session is constructed.

Fields

§file: &'static str
§line: u32
§logger: &'a str
§session: &'a str
§

SessionEnd

End of a session. Occurs when a logger session is destructed.

Fields

§elapsed: i64
§file: &'static str
§line: u32
§logger: &'a str
§session: &'a str

Implementations§

source§

impl Context<'_>

source

pub fn get_time(&self) -> &DateTime<Local>

Get the time of the context in Local timezone.

source

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

Get the level of the context. Only available for log messages.

source

pub fn get_file(&self) -> &str

Get the file of the context. Not available for session end.

source

pub fn get_line(&self) -> &u32

Get the line of the context.

source

pub fn get_logger(&self) -> &str

Get the logger entry name of the context.

source

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

Get the session name of the context.

source

pub fn get_message(&self) -> &str

Get the message of the context.

source

pub fn get_time_str(&self) -> String

Get the default formatted string of time. [YYYY]-[MM]-[DD]T[HH]:[mm]:[ss.ssssss]+[ZZ:ZZ]

source

pub fn get_name(&self) -> String

Get the default formatted string of name.

If session is none, the logger name is returned. Otherwise, the "{logger}:{session}" is returned.

source

pub fn get_location_str(&self) -> String

Get the default formatted string of location. "{file}:{line}"

Trait Implementations§

source§

impl<'a> Debug for Context<'a>

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for Context<'a>

§

impl<'a> RefUnwindSafe for Context<'a>

§

impl<'a> Send for Context<'a>

§

impl<'a> Sync for Context<'a>

§

impl<'a> Unpin for Context<'a>

§

impl<'a> UnwindSafe for Context<'a>

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

§

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

§

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.