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
impl Builder
pub fn new() -> Self
pub fn builder(self) -> Result<(), Box<dyn Error + Send + Sync>>
pub fn level(self, level: LevelFilter) -> Self
pub fn log_file(self, log_file: String) -> Self
pub fn log_file_max(self, log_file_max: u32) -> Self
pub fn use_console(self, use_console: bool) -> Self
pub fn use_async(self, use_async: bool) -> Self
pub fn level_str( self, level: &str, ) -> Result<Self, Box<dyn Error + Send + Sync>>
pub fn log_file_max_str( self, log_file_max: &str, ) -> Result<Self, Box<dyn Error + Send + Sync>>
pub fn plugin<T: Write + Send + Sync + 'static>(self, plugin: T) -> Self
pub fn filter(self, filter: impl CustomFilter) -> Self
Auto Trait Implementations§
impl Freeze for Builder
impl !RefUnwindSafe for Builder
impl Send for Builder
impl Sync for Builder
impl Unpin for Builder
impl !UnwindSafe for Builder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more