Expand description

simple-log is a very simple configuration log crates.

simple-log format output

2020-12-07 15:06:03.260570000 [INFO] <json_log:16>:info json simple_log
2020-12-07 15:06:03.262106000 [WARN] <json_log:17>:warn json simple_log
2020-12-07 15:06:03.262174000 [ERROR] <json_log:18>:error json simple_log

Quick Start

To get you started quickly, the easiest and quick way to used with demo or test project

#[macro_use]
extern crate simple_log;

fn main() {
   simple_log::quick!();

   debug!("test quick debug");
   info!("test quick info");
}

Usage in project

Configuration LogConfig in your project.

#[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("debug")
       .output_file()
       .output_console()
       .build();

   simple_log::new(config)?;
   debug!("test builder debug");
   info!("test builder info");
   Ok(())
}

Config with json

#[macro_use]
extern crate simple_log;

use simple_log::LogConfig;

fn main() {
    let config = r#"
    {
        "path":"./log/tmp.log",
        "level":"debug",
        "size":10,
        "out_kind":"file",
        "roll_count":10
    }"#;
    let log_config: LogConfig = serde_json::from_str(config).unwrap();

    simple_log::new(log_config).unwrap();//init log

    info!("info json simple_log");
    warn!("warn json simple_log");
    error!("error json simple_log");
}

For the user guide and futher documentation, please read The simple-log document.

More than examples can see: examples.

Re-exports

pub extern crate log;

Modules

Macros

Structs

The LogConfig with builder wrapper.

Functions

Provide init simple-log instance with stdout console on terminal.

Provide init simple-log instance with write file.

Get simple-log global config LogConfig

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

This method can quick init simple-log with no configuration.

Update simple-log global config LogConfig.

update simple-log global config log level.

Type Definitions