@@ -8,10 +8,15 @@ use axum::{
88use serde:: Deserialize ;
99use std:: time:: Duration ;
1010use tokio:: net:: TcpListener ;
11+ use tower_http:: trace:: TraceLayer ;
12+ use tracing:: { Level , info} ;
13+ use tracing_subscriber:: FmtSubscriber ;
1114
1215async fn spawn_repository_checker ( repo_url : & str , interval : Duration ) {
1316 let repo_url = repo_url. to_string ( ) ;
17+ info ! ( "Spawning repository checker for {}" , repo_url) ;
1418 tokio:: spawn ( async move {
19+ info ! ( "Starting repository link check for {}" , repo_url) ;
1520 check_repository_links ( & repo_url, interval) . await ;
1621 } ) ;
1722}
@@ -27,6 +32,10 @@ struct CheckRequest {
2732}
2833
2934async fn check_handler ( Json ( payload) : Json < CheckRequest > ) -> & ' static str {
35+ info ! (
36+ "Received check request for repository: {}" ,
37+ payload. repo_url
38+ ) ;
3039 let interval = Duration :: from_secs ( payload. interval_secs ) ;
3140 spawn_repository_checker ( & payload. repo_url , interval) . await ;
3241 "Repository checker started"
@@ -44,8 +53,23 @@ async fn cancel_handler(Json(payload): Json<CancelRequest>) -> &'static str {
4453
4554#[ tokio:: main]
4655async fn main ( ) {
56+ FmtSubscriber :: builder ( )
57+ . with_max_level ( Level :: INFO )
58+ . with_target ( false )
59+ . with_thread_ids ( true )
60+ . with_file ( true )
61+ . with_line_number ( true )
62+ . with_thread_names ( true )
63+ . with_level ( true )
64+ . with_ansi ( true )
65+ . pretty ( )
66+ . init ( ) ;
67+
68+ info ! ( "Starting Queensac service..." ) ;
69+
4770 let app = app ( ) ;
4871 let listener = TcpListener :: bind ( "localhost:3000" ) . await . unwrap ( ) ;
72+ info ! ( "Server listening on localhost:3000" ) ;
4973
5074 serve ( listener, app) . await . unwrap ( ) ;
5175}
@@ -56,4 +80,5 @@ fn app() -> Router {
5680 . route ( "/health" , get ( health_check) )
5781 . route ( "/check" , post ( check_handler) )
5882 . route ( "/cancel" , delete ( cancel_handler) )
83+ . layer ( TraceLayer :: new_for_http ( ) )
5984}
0 commit comments