Struct Logger

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

A logger that can handle log records

Implementations§

Source§

impl Logger

Source

pub fn new(level: LogLevel) -> Self

Create a new logger with the given log level

Source

pub fn level(&self) -> LogLevel

Get the log level

Source

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

Set the log level

Source

pub fn add_handler(&mut self, handler: Arc<RwLock<dyn Handler>>) -> &mut Self

Add a handler to the logger

Source

pub fn remove_handler(&mut self, handler: Arc<RwLock<dyn Handler>>) -> &mut Self

Remove a handler from the logger

Source

pub fn set_async( &mut self, enable: bool, queue_size: Option<usize>, ) -> &mut Self

Enable or disable async logging

Source

pub fn set_worker_threads(&mut self, count: usize) -> &mut Self

Set the number of worker threads for async logging

Source

pub fn log(&self, record: &Record) -> bool

Log a record

Source

pub fn log_message(&self, level: LogLevel, message: impl Into<String>) -> bool

Log a message at the given level with fluent API

Source

pub fn debug(&self, message: impl Into<String>) -> bool

Log a debug message

Source

pub fn info(&self, message: impl Into<String>) -> bool

Log an info message

Source

pub fn warn(&self, message: impl Into<String>) -> bool

Log a warning message

Source

pub fn error(&self, message: impl Into<String>) -> bool

Log an error message

Source

pub fn set_enabled(&self, enabled: bool) -> &Self

Enable or disable the logger

Source

pub fn is_enabled(&self) -> bool

Check if the logger is enabled

Source

pub fn handlers(&self) -> &[Arc<RwLock<dyn Handler>>]

Get all registered handlers

Source

pub fn is_async(&self) -> bool

Check if async logging is enabled

Trait Implementations§

Source§

impl Clone for Logger

Source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Logger

Source§

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

Formats the value using the given formatter. Read more

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.