Struct session_log::Logger

source ·
pub struct Logger { /* private fields */ }
Expand description

Logger is the base type that actually handle the loggings

Implementations§

source§

impl Logger

source

pub fn default(name: impl Into<String>) -> Self

Creating a new logger with the given name & default configurations.

source§

impl Logger

source

pub fn new<F: Formatter>(name: impl Into<String>, config: Config) -> Self

Creating a new logger with the given name.

source

pub fn session(&self, name: &str, silent: bool) -> Session

Create a new session from the logger.

There are two types of session: silent & non-silent. Silent session will not print the header and footer of the session when no message is logged before the session is dropped. It’s useful session that may potentially not log anything. Non-silent session will always print the header and footer of the session.

Due to the uncertainty of if the session will log anything, the header will be deferred until the first log. If the session logged anything, it’ll act like a non-silent session.

source

pub fn session_then<F, T>(&self, name: &str, silent: bool, callable: F) -> T
where F: FnOnce(Session) -> T,

Create a new session from the session and execute the callable with the session passed in.

This can be handy for isolating the environment of each callable while also providing a common logging interface for any callable that needs to be logged.

Trait Implementations§

source§

impl Loggable for Logger

source§

fn root_name(&self) -> &str

Get the name of the root logger.
source§

fn name(&self) -> &str

Get the name of current logger.
source§

fn path(&self) -> String

Get the path of the log file.
source§

fn write_level(&self) -> Level

Get the writing level of the root logger.
source§

fn print_level(&self) -> Level

Get the printing level of the root logger.
source§

fn debug(&self, message: &str)

Log a message with debug level.
source§

fn verbose(&self, message: &str)

Log a message with verbose level.
source§

fn info(&self, message: &str)

Log a message with info level.
source§

fn warning(&self, message: &str)

Log a message with warning level.
source§

fn critical(&self, message: &str)

Log a message with critical level.
source§

fn error(&self, message: &str)

Log a message with error level.
source§

fn fatal(&self, message: &str) -> !

Log a message with fatal level. The program will panic after logging the message.

Auto Trait Implementations§

§

impl Freeze for Logger

§

impl RefUnwindSafe for Logger

§

impl Send for Logger

§

impl Sync for Logger

§

impl Unpin for Logger

§

impl UnwindSafe for Logger

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.