Struct Logger

Source
pub struct Logger<'o> { /* private fields */ }
Expand description

A logger that can log messages on different level to different output.
The output of each level can be configured to eventually be same for all, or unique.

Implementations§

Source§

impl<'o> Logger<'o>

Source

pub fn new() -> Option<Self>

Create a new logger. By default, INFO and DEBUG are writting to stdout, and WARNING and ERROR write to stderr.

§Return Value

The new logger if the function succeeded, None otherwise.

Source

pub fn config_format<S: ToString + ?Sized>(&mut self, new_format: &S)

Configure the format of the log.

§Arguments
  • new_format - The format to be used for logging message.
    Any occurrence of %l will be replaced by the level, %t by the timestamp, %m by the message.
Source

pub fn config_info(&mut self, kind: OutputKind<'o>)

Configure the output for INFO.

§Arguments
  • kind - The new output kind to be used by the info.
Source

pub fn config_debug(&mut self, kind: OutputKind<'o>)

Configure the output for DEBUG.

§Arguments
  • kind - The new output kind to be used by the debug.
Source

pub fn config_warning(&mut self, kind: OutputKind<'o>)

Configure the output for WARNING.

§Arguments
  • kind - The new output kind to be used by the warning.
Source

pub fn config_error(&mut self, kind: OutputKind<'o>)

Configure the output for ERROR.

§Arguments
  • kind - The new output kind to be used by the error.
Source

pub fn info(&mut self, msg: &str)

Send a message on INFO.

§Arguments
  • msg - The message to write on INFO.
Source

pub fn debug(&mut self, msg: &str)

Send a message on DEBUG.

§Arguments
  • msg - The message to write on DEBUG.
Source

pub fn warning(&mut self, msg: &str)

Send a message on WARNING.

§Arguments
  • msg - The message to write on WARNING.
Source

pub fn error(&mut self, msg: &str)

Send a message on ERROR.

§Arguments
  • msg - The message to write on ERROR.

Auto Trait Implementations§

§

impl<'o> Freeze for Logger<'o>

§

impl<'o> !RefUnwindSafe for Logger<'o>

§

impl<'o> !Send for Logger<'o>

§

impl<'o> !Sync for Logger<'o>

§

impl<'o> Unpin for Logger<'o>

§

impl<'o> !UnwindSafe for Logger<'o>

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.