tracing

main
pantonshire 3 years ago
parent bcc8a434a4
commit fae98150cd

@ -8,16 +8,18 @@ use std::{
task::{Context, Poll}, task::{Context, Poll},
sync::Arc, sync::Arc,
thread::{JoinHandle, self}, thread::{JoinHandle, self},
net::SocketAddr,
io, io,
fmt, fmt,
error, error,
panic, net::SocketAddr, panic,
}; };
use axum::{Router, Server, Extension}; use axum::{Router, Server, Extension};
use notify::{RecommendedWatcher, RecursiveMode, Watcher}; use notify::{RecommendedWatcher, RecursiveMode, Watcher};
use tera::Tera; use tera::Tera;
use tokio::sync::RwLock as TokioRwLock; use tokio::sync::RwLock as TokioRwLock;
use tracing::{debug, info, error};
use treacle::Debouncer; use treacle::Debouncer;
const DEFAULT_TEMPLATES_DEBOUNCE_TIME: Duration = Duration::from_millis(500); const DEFAULT_TEMPLATES_DEBOUNCE_TIME: Duration = Duration::from_millis(500);
@ -104,7 +106,7 @@ impl<'a, F> Mallard<'a, F> {
}, },
Err(err) => { Err(err) => {
// FIXME: custom error handler // FIXME: custom error handler
eprintln!("Filesystem event error: {}", err); error!(error = %err, "filesystem event error");
}, },
})?; })?;
@ -118,25 +120,25 @@ impl<'a, F> Mallard<'a, F> {
move || { move || {
while let Ok(()) = debounced_rx.recv() { while let Ok(()) = debounced_rx.recv() {
// FIXME: tracing debug!("reloading templates");
let reload_res = { let reload_res = {
let mut guard = ctx.tera().blocking_write(); let mut guard = ctx.tera().blocking_write();
guard.full_reload() guard.full_reload()
}; };
// FIXME: custom error handler
match reload_res { match reload_res {
Ok(()) => { Ok(()) => {
// println!("Reloaded templates"); info!("reloaded templates");
}, },
Err(_) => { Err(err) => {
// eprintln!("Error reloading templates: {}", err); // FIXME: custom error handler
error!(error = %err, "failed to reload templates");
}, },
} }
} }
// println!("Stopping template reloader thread"); info!("stopped template reloader thread")
} }
})?; })?;

Loading…
Cancel
Save