Struct Builder

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

Builder is a struct that holds the configuration for the logger.

The level field is the minimum log level that will be logged. The log_file field is the name of the log file. The log_file_max field is the maximum size of the log file in megabytes. The use_console field is a boolean that indicates whether or not to log to the console. The use_async field is a boolean that indicates whether or not to use an asynchronous logger.

The new() method

Properties:

  • level: The log level to use.
  • log_file: The name of the log file.
  • log_file_max: The maximum number of log files to keep.
  • use_console: If true, the logger will log to the console.
  • use_async: Whether to use the async logger or not.
  • filter: Use user-defined log filtering functions.
  • plugin: Use a user-defined log output plug-in.

§Examples

asnyclog::Builder::new()
    .level(log::LevelFilter::Debug)
    .log_file(String::from("./app.log"))
    .log_file_max(1024 * 1024)
    .use_console(true)
    .use_async(true)
    .filter(|r: &log::Record| r.target() != "gensql::sql_builder" || r.line().unwrap_or(0) != 72)
    .builder()?;

Implementations§

Source§

impl Builder

Source

pub fn new() -> Self

Source

pub fn builder(self) -> Result<(), Box<dyn Error + Send + Sync>>

Source

pub fn level(self, level: LevelFilter) -> Self

Source

pub fn log_file(self, log_file: String) -> Self

Source

pub fn log_file_max(self, log_file_max: u32) -> Self

Source

pub fn use_console(self, use_console: bool) -> Self

Source

pub fn use_async(self, use_async: bool) -> Self

Source

pub fn level_str( self, level: &str, ) -> Result<Self, Box<dyn Error + Send + Sync>>

Source

pub fn log_file_max_str( self, log_file_max: &str, ) -> Result<Self, Box<dyn Error + Send + Sync>>

Source

pub fn plugin<T: Write + Send + Sync + 'static>(self, plugin: T) -> Self

Source

pub fn filter(self, filter: impl CustomFilter) -> Self

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