From fae98150cd23158a9d08e3f9a3a565f4779a3ccf Mon Sep 17 00:00:00 2001 From: pantonshire Date: Mon, 1 May 2023 19:35:21 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20tracing?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/lib.rs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 506f980..e2f9bd9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -8,16 +8,18 @@ use std::{ task::{Context, Poll}, sync::Arc, thread::{JoinHandle, self}, + net::SocketAddr, io, fmt, error, - panic, net::SocketAddr, + panic, }; use axum::{Router, Server, Extension}; use notify::{RecommendedWatcher, RecursiveMode, Watcher}; use tera::Tera; use tokio::sync::RwLock as TokioRwLock; +use tracing::{debug, info, error}; use treacle::Debouncer; const DEFAULT_TEMPLATES_DEBOUNCE_TIME: Duration = Duration::from_millis(500); @@ -104,7 +106,7 @@ impl<'a, F> Mallard<'a, F> { }, Err(err) => { // 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 || { while let Ok(()) = debounced_rx.recv() { - // FIXME: tracing + debug!("reloading templates"); let reload_res = { let mut guard = ctx.tera().blocking_write(); guard.full_reload() }; - // FIXME: custom error handler match reload_res { Ok(()) => { - // println!("Reloaded templates"); + info!("reloaded templates"); }, - Err(_) => { - // eprintln!("Error reloading templates: {}", err); + Err(err) => { + // FIXME: custom error handler + error!(error = %err, "failed to reload templates"); }, } } - // println!("Stopping template reloader thread"); + info!("stopped template reloader thread") } })?;