use std::{fs::File, sync::Mutex, time::Instant};
use time::macros::offset;
use tracing_rolling::{Checker, ConstFile, Daily};
fn main() {
let log_file = File::options()
.append(true)
.create(true)
.write(true)
.open("logs/app.log")
.unwrap();
let (writer, token) = Daily::new("logs/testing.log", "[year][month][day]", offset!(+8))
.buffer_with(8192) .build()
.unwrap();
let (c, tc) = ConstFile::new("logs/c.log")
.buffer_with(8192)
.build()
.unwrap();
tracing_subscriber::fmt()
.with_ansi(false)
.with_writer(c)
.init();
let now = Instant::now();
let count = 1000000;
for _ in 0..count {
tracing::info!("all is well");
}
drop(tc);
drop(token);
eprintln!(
"{:?} us/log",
now.elapsed().as_micros() as f64 / (count as f64)
);
}