info.remote_addr() - method not found in warp::log::Info
17:49 09 Jan 2026

I'm learning rust web development.I'm trying to do chapter 6(logging in warp)

Below is the rust code example in the book-

#[tokio::main]
async fn main() {
 log4rs::init_file("log4rs.yaml", Default::default()).unwrap();
 log::error!("This is an error!");
 log::info!("This is info!");
 log::warn!("This is a warning!");
 
 let log = warp::log::custom(|info| {
 eprintln!(
    "{} {} {} {:?} from {} with {:?}",
    info.method(),
    info.path(),
    info.status(),
    info.elapsed(),
    info.remote_addr().unwrap(),
    info.request_headers()
    );
 });
 
 let routes = get_questions
    .or(update_question)
    .or(add_question)
    .or(add_answer)
    .or(delete_question)
    .with(cors)
    .with(log)
    .recover(return_error);
 
 
 warp::serve(routes).run(([127, 0, 0, 1], 3030)).await;
}
}

info.remote_addr().unwrap(), is not compiling. I'm getting below error

error[E0599]: no method named `remote_addr` found for struct `warp::log::Info<'a>` in the current scope
 --> src/main.rs:9:14
  |
9 |         info.remote_addr().unwrap(),
  |              ^^^^^^^^^^^ method not found in `warp::log::Info<'_>`

I tried to look online I found something like below wich only logs remote address not other middleware parameters.

let log_details = warp::filters::addr::remote()
        .and(warp::method())
        .map(|addr: Option, method: Method| {
            println!("Request: {:?} {:?}", method, addr);
        })
        .untuple_one();

    
    let routes = log_details
        .and(warp::any())
        .map(|| "Hello, world!");

How can I get this work correctly and produce correct output?

rust rust-warp