little_hyper/
logger.rs

1use crate::Request;
2
3/// Logger
4/// 
5/// 
6#[derive(Default)]
7pub struct Logger {
8    log: bool,
9}
10
11impl Logger {
12    pub fn new(log: bool) -> Self {
13        Self { log }
14    }
15
16    pub fn set(&mut self, log: bool) {
17        self.log = log;
18    }
19
20    /// Request
21    /// 
22    /// Log the request
23    pub fn request(&self, request: &Request) {
24        if !self.log {
25            return;
26        }
27
28        println!(
29            "{method:<6} {path}",
30            method = request.method,
31            path = request.path
32        );
33    }
34}