Type checker needs to know the type of buf there, which I believe is &mut env_logger::fmt::Formatter. In addition, you need to use std::io::Write so the writeln! can call write_fmt on it. So make the closure