pub fn apache_common(
    request_id: impl LogFormatter,
    user_id: impl LogFormatter
) -> impl LogFormatter
Expand description

apache common log format

This is defined as follows:

ip request_id user_id \[timestamp\]method url versionstatus bytes

where request_id and user_id are mandatory formatters provided at time of usage.

usage without request_id or user_id

Logger::new().with_formatter(apache_common("-", "-"));

usage with app-specific user_id

fn user(conn: &Conn, color: bool) -> Cow<'static, str> {
     match conn.state::<User>() {
        Some(user) => String::from(user.name()).into(),
        None => "guest".into()
    }
}

Logger::new().with_formatter(apache_common("-", user));