gendx / lzma-rs

An LZMA decoder written in pure Rust
MIT License
128 stars 27 forks source link

Make debug/tracing optional #18

Closed gendx closed 4 years ago

gendx commented 4 years ago

The tracing macros such as info!, debug! or trace! from the log crate are not compiled away in release mode, because tracing can be enabled at runtime (via env_logger).

In principle, tracing can be disabled at compile time by enabling some features in the log crate (https://docs.rs/log/0.4.8/log/#compile-time-filters). However, enabling a feature for a crate affects all code that also depend on this crate within a build. So if a binary depends on lzma-rs and wants to log something else, then it cannot optimize away logging in lzma-rs via log's features.

A better solution would be to have a feature in lzma-rs to enable logging (as it is mostly useful for developing lzma-rs). By default, this logging feature will be off so that users of lzma-rs see a performance improvement in general.