Function simple_log::new

source · []
pub fn new(log_config: LogConfig) -> SimpleResult<()>
Expand description

The new method provide init simple-log instance with config.

This method need pass LogConfig param. Your can use LogConfigBuilder build LogConfig. Also you can use serde with Deserialize init LogConfig.

Examples

#[macro_use]
extern crate simple_log;

use simple_log::LogConfigBuilder;

fn main() -> Result<(), String> {
   let config = LogConfigBuilder::builder()
           .path("./log/builder_log.log")
           .size(1 * 100)
           .roll_count(10)
           .level("info")
           .output_file()
           .output_console()
           .build();
    simple_log::new(config)?;
    debug!("test builder debug");
    info!("test builder info");
    Ok(())
}