Crates.io | tracing_storage_logger |
lib.rs | tracing_storage_logger |
version | 0.1.16 |
source | src |
created_at | 2022-08-14 20:20:20.27097 |
updated_at | 2022-08-31 00:32:52.748977 |
description | Easy rotating logs for the tracing crate. |
homepage | |
repository | |
max_upload_size | |
id | 645553 |
size | 35,324 |
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.
// 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");
}