Skip to content

Commit f8ab161

Browse files
authored
Merge pull request #31 from junkurihara/feat/tracing-optional
Feat/tracing optional
2 parents 002c430 + 46663ef commit f8ab161

3 files changed

Lines changed: 48 additions & 7 deletions

File tree

httpsig-hyper/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ impl std::str::FromStr for ContentDigestType {
5858
pub use error::{HyperDigestError, HyperDigestResult, HyperSigError, HyperSigResult};
5959
pub use httpsig::prelude;
6060
pub use hyper_content_digest::{ContentDigest, RequestContentDigest, ResponseContentDigest};
61-
pub use hyper_http::{
62-
MessageSignature, MessageSignatureReq, MessageSignatureReqSync, MessageSignatureRes, MessageSignatureResSync,
63-
};
61+
pub use hyper_http::{MessageSignature, MessageSignatureReq, MessageSignatureRes};
62+
#[cfg(feature = "blocking")]
63+
pub use hyper_http::{MessageSignatureReqSync, MessageSignatureResSync};
6464

6565
/* ----------------------------------------------------------------- */
6666
#[cfg(test)]

httpsig/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,13 @@ rust-version.workspace = true
1313
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
1414

1515
[features]
16-
default = []
16+
default = ["tracing"]
1717
rsa-signature = ["rsa"]
18+
tracing = ["dep:tracing"]
1819

1920
[dependencies]
2021
thiserror = { version = "2.0.19" }
21-
tracing = { version = "0.1.44" }
22+
tracing = { version = "0.1.44", default-features = false, optional = true }
2223
rustc-hash = { version = "2.1.3" }
2324
indexmap = { version = "2.14.0" }
2425
rand = { version = "0.10.2" }
@@ -56,4 +57,3 @@ base64 = { version = "0.22.1" }
5657

5758
# for rfc8941 structured field values
5859
sfv = { version = "0.15.0" }
59-

httpsig/src/trace.rs

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,43 @@
1+
#[cfg(feature = "tracing")]
12
#[allow(unused)]
2-
pub use tracing::{debug, error, info, trace, warn};
3+
pub(crate) use tracing::{debug, error, info, trace, warn};
4+
5+
/// No-op macros used when the `tracing` feature is disabled.
6+
/// They expand to `()` so that they are usable both in statement and
7+
/// expression positions, like the original `tracing` macros.
8+
/// `warn` is defined as `warn_` and re-exported, since a macro named
9+
/// `warn` conflicts with the built-in `warn` attribute (E0659).
10+
#[cfg(not(feature = "tracing"))]
11+
mod noop {
12+
#![allow(unused_macros)]
13+
macro_rules! debug {
14+
($($arg:tt)*) => {
15+
()
16+
};
17+
}
18+
macro_rules! error {
19+
($($arg:tt)*) => {
20+
()
21+
};
22+
}
23+
macro_rules! info {
24+
($($arg:tt)*) => {
25+
()
26+
};
27+
}
28+
macro_rules! trace {
29+
($($arg:tt)*) => {
30+
()
31+
};
32+
}
33+
macro_rules! warn_ {
34+
($($arg:tt)*) => {
35+
()
36+
};
37+
}
38+
#[allow(unused_imports)]
39+
pub(crate) use {debug, error, info, trace, warn_ as warn};
40+
}
41+
#[cfg(not(feature = "tracing"))]
42+
#[allow(unused)]
43+
pub(crate) use noop::*;

0 commit comments

Comments
 (0)