1 unstable release
0.7.1 | Nov 10, 2022 |
---|---|
0.6.3 |
|
0.5.0 |
|
0.4.0 |
|
0.0.1 |
|
#575 in Debugging
85 downloads per month
Used in 3 crates
8KB
115 lines
logs
A simple terminal logger
Usage
Add this in your Cargo.toml
:
[dependencies]
logs = "*"
Example
use logs::{debug, error, info, trace, warn, Logs};
fn main() {
Logs::new().init();
trace!("This is a trace log");
debug!("This is a debug log");
info!("This is a info log");
warn!("This is a warn log");
error!("This is a error log");
}
Output:
2022-09-06T08:38:23.490 [TRACE] This is a trace log
2022-09-06T08:38:23.490 [DEBUG] This is a debug log
2022-09-06T08:38:23.490 [INFO ] This is a info log
2022-09-06T08:38:23.490 [WARN ] This is a warn log
2022-09-06T08:38:23.490 [ERROR] This is a error log
Options
use logs::{Logs, debug, error, LevelFilter};
fn main() {
Logs::new()
// Show log level color
.color(true)
// Filter log target
.target("target")
// Filter log level
.level(LevelFilter::Info)
// Filter log target from `LOG` environment variable
.level_from_default_env()
.unwrap()
// Filter log target from `NAME` environment variable
.level_from_env("NAME")
.unwrap()
// Filter log level from str
.level_from_str("info")
.unwrap()
// Apply
.init();
}
Dependencies
~1MB
~15K SLoC