Skip to main content

nimble_http/
debug.rs

1use crate::Router;
2use hyper::{Method, StatusCode};
3
4impl Router {
5	pub fn debug(mut self) -> Self {
6		self.enable_logger = true;
7		self
8	}
9
10	pub(crate) fn request_log(
11		&mut self,
12		ip: String,
13		method: &Method,
14		path: String,
15		status: StatusCode,
16	) {
17		self.log(&format!(
18			"{} {} {} -> {} ({})",
19			ip,
20			method,
21			path,
22			status.as_u16(),
23			status.canonical_reason().unwrap_or("Unknown")
24		));
25	}
26
27	pub(crate) fn log(&mut self, msg: &str) {
28		let mut outputs = self.outputs.lock().unwrap();
29		*outputs += msg;
30		*outputs += "\n";
31		println!("{}", msg);
32	}
33}