Home

Write An Hourly Log File With Rust

This creates a logger and writes out an hourly file. There's a lot of other options for this and some of the options aren't being used yet. (This page is still a work in progress), but this works

use tracing::{debug, error, info, span, warn, Level};

fn main() {
    let file_appender = tracing_appender::rolling::hourly("/Users/alan/Desktop", "prefix.log");
    let (non_blocking, _guard) = tracing_appender::non_blocking(file_appender);
    tracing_subscriber::fmt().with_writer(non_blocking).init();
    info!["this is info"];
    println!("Hello, world!");
    alfa("yo");
}

#[tracing::instrument]
fn alfa(ping: &str) {
    info!["here"];
    println!("{}", ping);
}

Needs:

~ fin ~