========================================
This is a Rust Log Crate. Log output is mainly achieved through macros. Log composite output will be supported in future releases. The following features are now supported.
The current version is preliminary and will get better in the future.
lazy-static.rs is available on crates.io. It is recommended to look there for the newest released version, as well as links to the newest builds of the docs.
At the point of the last update of this README, the latest published version could be used like this:
Add the following dependency to your Cargo manifest...
rust
[dependencies]
wd_log = "0.1"
rust
//Set log level, default:Debug
wd_log::set_level(wd_log::INFO);
//Set the log output prefix, default:"wd_log"
wd_log::set_prefix("WDLOG");
//Whether to display the print time, default:true
wd_log::show_time(false);
//Whether to display the location, default:true
wd_log::show_file_line(false);
//Set output to a file, default:stdout
wd_log::output_to_file("./log.txt").expect("file open failed");
rust
wd_log::log_debug!("hello world");
wd_log::log_debug_ln!("hello world");
wd_log::log_info!("hello world");
wd_log::log_info_ln!("hello world");
wd_log::log_warn!("hello world");
wd_log::log_warn_ln!("hello world");
wd_log::log_error!("hello world");
wd_log::log_error_ln!("hello world");
rust
wd_log::log_debug!();
wd_log::log_debug!("{} {}","hello","world");
rust
//After printing, trigger panic.
wd_log::log_panic!("hello world");
if result if Ok(T), direct return Some(T) ```rust let result = Err("hello"); let res:Option<()> = wdlog::reserror!(result); let _res:Option<()> = wdlog::reserrorln!(result);
let res:Option<()> = wdlog::reserror!(result;"this is {}","error"); let _res:Option<()> = wdlog::reserrorln!(result;"this is {}","error");
let result:Result<&str,&str> = Ok("world"); let res:Option<&str> = wdlog::reserror!(result); assert_eq!(res,Some("world")) ```
rust
let result:Result<&str,&str> = Ok("hello");
let res = wd_log::res_panic!(result;"succes");
println!("{}",res);
let result = Err("hello");
//It can lead to panic
let _ = wd_log::res_panic!(result;"this is {}","error");
Licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.