Skip to content

Add feature to inhibit log capture #219

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

Merged
merged 1 commit into from
Nov 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ description = "C-to-rustls bindings"
edition = "2018"
links = "rustls_ffi"

[features]
# Enable this feature when building as Rust dependency. It inhibits the
# default behavior of capturing the global logger, which only works when
# built using the Makefile, which passes -C metadata=rustls-ffi to avoid
# interfering with copies of the global logger brought in by other Rust
# libraries.
no_log_capture = []

[dependencies]
# Keep in sync with RUSTLS_CRATE_VERSION in build.rs
rustls = { version = "=0.20", features = [ "dangerous_configuration" ] }
Expand Down
4 changes: 4 additions & 0 deletions src/log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ impl log::Log for Logger {
fn flush(&self) {}
}

#[cfg(feature = "no_log_capture")]
pub(crate) fn ensure_log_registered() {}

#[cfg(not(feature = "no_log_capture"))]
pub(crate) fn ensure_log_registered() {
log::set_logger(&Logger {}).ok();
log::set_max_level(log::LevelFilter::Debug)
Expand Down