use hyper::{Method,Request};
pub fn log_request(req: &Request) {
let color = match req.method() {
&Method::Get => "\x1b[92m",
&Method::Post => "\x1b[93m",
&Method::Put => "\x1b[94m",
&Method::Head => "\x1b[95m",
_ => "",
};
println!("{}[{}]: {:?} {:?} (from {:?})\x1b[39m",
color,
::time::now().rfc3339(),
req.method(),
req.path(),
req.remote_addr(),
);
}
pub fn log_error(msg: String) {
println!(
"\x1b[91m[{}]: {}\x1b[39m",
::time::now().rfc3339(),
msg);
}
macro_rules! error {
($fmt:expr) => { ::util::log_error(format!($fmt)) };
($fmt:expr, $( $args:expr ),*) => {
::util::log_error(format!($fmt, $( $args ),*)) }
}