Skip to main content

Logger

Struct Logger 

Source
pub struct Logger { /* private fields */ }
Expand description

The logger entity

Filters logs based on a provided severity level and writes those logs to a file

Implementations§

Source§

impl Logger

Source

pub fn new(file: &str) -> Self

Create a new logger with a given log file path

§Arguments
  • file: A path to a file to which logs will be written
§Panics

This function might panic if opening the log file returns an Err

Source

pub fn set_level(&mut self, level: LogLevel)

Set the logger’s log level

This log level indicates the minimum log level allowed to be written to the log file

§Arguments
  • level: The minimum log level for filtering
Source

pub fn log(&self, message: &str)

Log a message without a specified log level

§Arguments
  • message: A message string to log to the log file
§Panics

This function might panic if it fails to get a lock on the file mutex

Source

pub fn log_with_level(&self, level: LogLevel, message: &str)

Log a message with a specified log level

§Arguments
  • level: The log level of the message
  • message: The message to log to the log file
§Panics

This function might panic if retrieving the duration since the Unix epoch fails

Source

pub fn debug(&self, message: &str)

Write a debug log

§Arguments
  • message: The message to log to the log file
Source

pub fn info(&self, message: &str)

Write an info log

§Arguments
  • message: The message to log to the log file
Source

pub fn warn(&self, message: &str)

Write a warning log

§Arguments
  • message: The message to log to the log file
Source

pub fn error(&self, message: &str)

Write an error log

§Arguments
  • message: The message to log to the log file
Source

pub fn critical(&self, message: &str)

Write a critical log

§Arguments
  • message: The message to log to the log file
Source

pub fn emergency(&self, message: &str)

Write an emergency log

§Arguments
  • message: The message to log to the log file

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

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.