tracing_storage_logger

Crates.iotracing_storage_logger
lib.rstracing_storage_logger
version0.1.16
sourcesrc
created_at2022-08-14 20:20:20.27097
updated_at2022-08-31 00:32:52.748977
descriptionEasy rotating logs for the tracing crate.
homepage
repository
max_upload_size
id645553
size35,324
(DiamondDDF)

documentation

README

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");
}
Commit count: 0

cargo fmt