diff --git a/Cargo.lock b/Cargo.lock index 1fcdf5f..bfa9fb0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,6 +2,15 @@ # It is not intended for manual editing. version = 4 +[[package]] +name = "log" +version = "0.4.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e5032e24019045c762d3c0f28f5b6b8bbf38563a65908389bf7978758920897" + [[package]] name = "workshop" version = "0.1.0" +dependencies = [ + "log", +] diff --git a/Cargo.toml b/Cargo.toml index 736105a..05d5558 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,3 +4,4 @@ version = "0.1.0" edition = "2024" [dependencies] +log = "0.4" \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index 126a0cc..d5f5f43 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,6 @@ use std::io::{Read, Write}; use std::net::{TcpListener, TcpStream}; +use log::info; fn main() -> std::io::Result<()> { let listener = TcpListener::bind("127.0.0.1:7878")?; @@ -13,7 +14,7 @@ fn main() -> std::io::Result<()> { fn handle_connection(mut stream: TcpStream) -> std::io::Result<()> { let mut buffer = [0; 1024]; stream.read(&mut buffer)?; - println!("Request: {}", String::from_utf8_lossy(&buffer[..])); + info!("Request: {}", String::from_utf8_lossy(&buffer[..])); let contents = include_str!("hello.html"); let response = format!(