Function trillium_logger::formatters::apache_combined

source ·
pub fn apache_combined(
    request_id: impl LogFormatter,
    user_id: impl LogFormatter,
) -> impl LogFormatter
Expand description

apache combined log format

This is defined as follows:

apache_combined(request_id, user_id) request_header("referrer") request_header("user-agent")

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

§usage with empty request_id and user_id

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

§usage with an 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_combined("-", user));