logging module

main
Zynh Ludwig 2024-08-28 19:12:55 -07:00
parent d866fa37a6
commit 9b6445ec84
2 changed files with 14 additions and 10 deletions

12
src/logging.rs Normal file
View File

@ -0,0 +1,12 @@
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};
pub fn init_tracing() {
// Set up logging
tracing_subscriber::registry()
.with(
tracing_subscriber::EnvFilter::try_from_default_env()
.unwrap_or_else(|_| "nyazoom=debug,tower_http=debug".into()),
)
.with(tracing_subscriber::fmt::layer())
.init();
}

View File

@ -26,9 +26,8 @@ use tokio_util::{
use tower_http::{limit::RequestBodyLimitLayer, services::ServeDir, trace::TraceLayer};
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};
mod cache;
mod logging;
mod nyazoom_headers;
pub mod ssr;
mod state;
@ -51,14 +50,7 @@ pub mod error {
#[tokio::main]
async fn main() -> io::Result<()> {
// Set up logging
tracing_subscriber::registry()
.with(
tracing_subscriber::EnvFilter::try_from_default_env()
.unwrap_or_else(|_| "nyazoom=debug,tower_http=debug".into()),
)
.with(tracing_subscriber::fmt::layer())
.init();
logging::init_tracing();
// uses create_dir_all to create both .cache and serve inside it in one go
util::make_dir(".cache/serve").await?;