Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

env: Allow zero-allocation LogBuilder::format? #72

Closed
tomjakubowski opened this issue Jan 16, 2016 · 1 comment
Closed

env: Allow zero-allocation LogBuilder::format? #72

tomjakubowski opened this issue Jan 16, 2016 · 1 comment

Comments

@tomjakubowski
Copy link
Contributor

The the "format function" passed to LogBuilder::format must implement Fn(&LogBuilder) -> String. That is, it must allocate a new string on the heap for every message logged. The string is discarded immediately after env_logger::Logger writes to stderr.

Would you consider, instead, making the signature Fn(&LogBuilder, &mut std::io::Write) -> io::Result? That way, customized env loggers could write directly to stderr without creating a String.

@KodrAus
Copy link
Contributor

KodrAus commented Sep 24, 2017

Thanks for the suggestion @tomjakubowski! We did end up doing this in rust-cli/env_logger#19

@KodrAus KodrAus closed this as completed Sep 24, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants