I'm hesitant to open this issue, because I suspect it has an obvious answer that I'm missing.
Anyway...
I love the new dbg! macro in 1.32.0. But, given that its purpose is outputting debugging messages, should its output be suppressed in a project's release build? (cargo build --release)
This was discussed in the RFC: https://github.com/rust-lang/rfcs/pull/2361
I'm a fan of leaving this as-is -- I used dbg! in one of my "takes 2 minutes to run in release mode, and who knows how long in debug" projects, and was very glad for the output in release.
Maybe it would make sense for the dbg! documentation to point to log::debug! for when people want to leave these lines checked in? I'm not usually a fan of pointing to external crates from std, but since it's in the nursery (https://github.com/rust-lang-nursery/log) maybe it's ok to make an exception?
Maybe it would make sense for the
dbg!documentation to point tolog::debug!for when people want to leave these lines checked in? I'm not usually a fan of pointing to external crates fromstd, but since it's in the nursery (https://github.com/rust-lang-nursery/log) maybe it's ok to make an exception?
We already do that, https://doc.rust-lang.org/nightly/std/macro.dbg.html -- but it could use some linkification and elaboration...
If there are no people that are willing to pick this up, I don't mind picking this up!
If I understand the conversation correctly the work that needs to be done is basically:
dbg! macro will also work in release builds (for testing reasons). But should it should be discouraged to actually use it for logging in (published) release builds.log::debug! is better suited.If I have a wrong view of this or if anyone else wants to pick this up, please let me know!
But should it should be discouraged to actually use it for logging in (published) release builds.
Make it clear that if people want debug statements to work only in debug builds
log::debug!is better suited.
This is already the case.
Improve the documentation such that it's clear that the dbg! macro will also work in release builds (for testing reasons).
This remains to be done.
Most helpful comment
We already do that, https://doc.rust-lang.org/nightly/std/macro.dbg.html -- but it could use some linkification and elaboration...