use std::fmt; use tracing::Level; 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 = "surrealdb::net"; pub fn write() -> warp::filters::log::Log { warp::log::custom(|info| { event!( target: NAME, Level::INFO, "{} {} {} {:?} {} \"{}\" {:?}", OptFmt(info.remote_addr()), info.method(), info.path(), info.version(), info.status().as_u16(), OptFmt(info.user_agent()), info.elapsed(), ); }) }