Skip to content

Commit 244ea16

Browse files
authored
Add feature to inhibit log capture (#219)
This is necessary to work properly when built as a Rust dependency (a rare use case).
1 parent 59765f3 commit 244ea16

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

Cargo.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@ description = "C-to-rustls bindings"
66
edition = "2018"
77
links = "rustls_ffi"
88

9+
[features]
10+
# Enable this feature when building as Rust dependency. It inhibits the
11+
# default behavior of capturing the global logger, which only works when
12+
# built using the Makefile, which passes -C metadata=rustls-ffi to avoid
13+
# interfering with copies of the global logger brought in by other Rust
14+
# libraries.
15+
no_log_capture = []
16+
917
[dependencies]
1018
# Keep in sync with RUSTLS_CRATE_VERSION in build.rs
1119
rustls = { version = "=0.20", features = [ "dangerous_configuration" ] }

src/log.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ impl log::Log for Logger {
3030
fn flush(&self) {}
3131
}
3232

33+
#[cfg(feature = "no_log_capture")]
34+
pub(crate) fn ensure_log_registered() {}
35+
36+
#[cfg(not(feature = "no_log_capture"))]
3337
pub(crate) fn ensure_log_registered() {
3438
log::set_logger(&Logger {}).ok();
3539
log::set_max_level(log::LevelFilter::Debug)

0 commit comments

Comments
 (0)