use log::Level; use std::fmt; struct OptFmt(Option); impl fmt::Display for OptFmt { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { if let Some(ref t) = self.0 { fmt::Display::fmt(t, f) } else { f.write_str("-") } } } const NAME: &str = "surreal::web"; pub fn write() -> warp::filters::log::Log { warp::log::custom(|info| { log!( target: NAME, Level::Info, "{} {} {} {:?} {} \"{}\" {:?}", OptFmt(info.remote_addr()), info.method(), info.path(), info.version(), info.status().as_u16(), OptFmt(info.user_agent()), info.elapsed(), ); }) }