Sure! I donāt mean to bring it in to the discussion too much, but fern is a log-crate backend that Iāve been working on, similar to log4rs - but focusing primarily on simple builder-based configuration.
I mention it just because @Geal was talking about format_args!() and a custom log formatter without allocating intermediate Strings, and Iāve recently added this feature to fern. In fern, the user provides a closure which always ends with a callback like out.finish(format_args!(...)) rather than returning anything.
This way no Strings are allocated intermediately, and format_args!() can still use newly-created data for the format, like the current time. Using this callback style, no changes are needed in the log crate in order to support allocation-less log formatting.
@Geal
I didnāt write this before, but I would be really interested in how you were wanting to implement format_args!() formatting! When I tried to do anything storing or returning an fmt::Arguments, I couldnāt get it to succeed - Iād be interested to know if it can work better with a args() method returning fmt::Arguments.
Even storing a simple fmt::Arguments in a variable failed for me:
extern crate chrono;
fn main() {
let timefmt = chrono::Local::now().format("%H:%M:%S");
let formatted = format_args!("{}", timefmt);
}
// error: borrowed value does not live long enough
(playpen)
The only workaround I found was using the result of format_args!() in a callback.