clux / loggerv

A minimalistic stdout/stderr logger for rust
https://docs.rs/loggerv
MIT License
21 stars 6 forks source link

Log to stdout/stderr without allocating #2

Closed daboross closed 7 years ago

daboross commented 7 years ago

Hi!

Hope this works here. Found this crate via some recent blog posts, and thought I'd see if I could help at all.

This commit removes the allocation of an intermediate String in log, so the log path is now allocation-free. This is likely a premature optimization, but it's a small change for much faster logging - and not allocation when not needed is a plus, in my mind.

clux commented 7 years ago

Hey there!

Yeah, this seems sensible to me. Maybe it's worth even avoiding the level variable by using writeln more generically on a reference to the correct stdout/err if we're going this direction.

My internet is a bit screwy at the moment, so will have to wait a bit to publish, a new version, but will merge this ASAP. :+1:

Thank you.

daboross commented 7 years ago

No problem, thank you for merging!

I don't think the level variable should have much of an impact since it's only on the stack, but making it more generic by using writeln could benefit clarity.