A library for logging. It is simple and easy to use. It is also lightweight and has a few dependencies :)
Cargo.toml
.src/main.rs
:
```rust
use dzl::Config;fn main() { // not write logs to files // let dzlconfig = Config::new(false, "dzl.log".tostring());
// use default config
let dzl_config = Config::default_config();
// initializing
dzl::init(&dzl_config);
// logging, you can also use `format!()` macro to format the string
dzl_config.trace("dzl".to_string());
dzl_config.info("dzl".to_string());
dzl_config.warn("dzl".to_string());
dzl_config.error("dzl".to_string());
// custom log type
dzl_config.custom("CustomType".to_string(), "dzl".to_string());
}
``
3. The logs will print to
stdoutor
stderr*(only for
errorlogger)*. If the field
writelogstofilesin struct
Configis false, logs will not write to the log file, they will only print to
stdoutor
stderr.
The default logging path is
dzl.log, you can change it with change the field
logpathin the struct
Configby use function
new()` with arguments.
You should make sure that the dictionary of log_path
exists. The library will only create file dzl.log
e.g. log_path: "dzl/dzl.log".to_string()
, the logs will write to file dzl/dzl.log
. 😀