pub fn init_log(
level: LevelFilter,
log_file: String,
log_file_max: u32,
use_console: bool,
use_async: bool,
) -> Result<(), Box<dyn Error + Send + Sync>>Expand description
It creates a new logger, initializes it, and then sets it as the global logger
Arguments:
level: log levellog_file: The log file path. ignore if the value is emptylog_file_max: The maximum size of the log file, The units that can be used are k/m/g.use_console: Whether to output to the consoleuse_async: Whether to use asynchronous logging, if true, the log will be written to the file in a separate thread, and the log will not be blocked.
Returns:
A Result<(), anyhow::error>
ยงExamples
asnyclog::init_log(log::LevelFilter::Debug, String::from("./app.log", 1024 * 1024, true, true)?;