use tokio::net::TcpStream; use tokio_rustls::server::TlsStream; pub struct RequestLogger { client_ip: String, request_url: String, } impl RequestLogger { pub fn new(stream: &TlsStream, request_url: String) -> Self { let client_ip = extract_client_ip(stream); Self { client_ip, request_url, } } pub fn log_success(self, status_code: u8) { println!("{} \"{}\" {}", self.client_ip, self.request_url, status_code); } pub fn log_error(self, status_code: u8, error_message: &str) { eprintln!("{} \"{}\" {} \"{}\"", self.client_ip, self.request_url, status_code, error_message); } } fn extract_client_ip(stream: &TlsStream) -> String { let (tcp_stream, _) = stream.get_ref(); match tcp_stream.peer_addr() { Ok(addr) => addr.to_string(), Err(_) => "unknown".to_string(), } } pub fn init_logging(_level: &str) { // Simple logging using stdout/stderr - systemd will capture this } #[cfg(test)] mod tests { #[test] fn test_basic_functionality() { // Basic test to ensure logging module compiles assert!(true); } }