17 releases
0.1.16 | Aug 31, 2022 |
---|---|
0.1.15 | Aug 29, 2022 |
#506 in Date and time
42 downloads per month
22KB
313 lines
This crate is for easily creating rotating logs using the tracing crate. I plan on using it for every project, so it will improve. Already it's better than solutions most other languages might have, I think. It works. But it's still very preliminary.
Examples
// prelude includes everything you need, including time zones:
use tracing_storage_logger::prelude::*;
fn main() {
// It's going to complain this is an unused variable. That's fine. Use an "_" underscore if you wish:
let logger = Logger::new(
// Root path for all logs would be [project_root]/logs,in this case:
PathBuf::from(r"logs"),
// Size of each file before rotating and adding a date:
ContentLimit::Bytes(1024),
// max number of files to archive for each file name:
4,
chrono_tz::US::Eastern
);
info!(message = "πΊπΊπΊ Cheers!", path = "general");
info!(message = "πππ Peace and beauty", path = "general");
function_a();
}
#[instrument(level = "trace")]
fn function_a(){
info!(message = "Inside function a", path = "Transactions", level = "error");
function_b();
warn!("Exiting function a");
}
#[instrument(level = "debug")]
fn function_b(){
info!("Inside function b");
function_c("Some message".into());
warn!("Exiting function b");
}
#[instrument]
fn function_c(some_argument: &str){
info!("Inside function c");
error!("Exiting function c");
}
Dependencies
~3.5β10MB
~95K SLoC