diff --git a/sentry-core/Cargo.toml b/sentry-core/Cargo.toml index 81a5eeda..043bd952 100644 --- a/sentry-core/Cargo.toml +++ b/sentry-core/Cargo.toml @@ -23,6 +23,7 @@ harness = false default = [] client = ["rand"] test = ["client", "release-health"] +debug_logs = [] release-health = [] logs = [] diff --git a/sentry-core/src/logs.rs b/sentry-core/src/logs.rs index 9be3ee33..523f47c2 100644 --- a/sentry-core/src/logs.rs +++ b/sentry-core/src/logs.rs @@ -105,7 +105,6 @@ impl LogsBatcher { } sentry_debug!("[LogsBatcher] Flushing {} logs", logs.len()); - if let Some(ref transport) = *transport.read().unwrap() { let mut envelope = Envelope::new(); let logs_item: EnvelopeItem = logs.into(); diff --git a/sentry-core/src/macros.rs b/sentry-core/src/macros.rs index edb75dcd..ca32a262 100644 --- a/sentry-core/src/macros.rs +++ b/sentry-core/src/macros.rs @@ -53,6 +53,7 @@ macro_rules! with_client_impl { // TODO: temporarily exported for use in `sentry` crate #[macro_export] #[doc(hidden)] +#[cfg(feature = "debug_logs")] macro_rules! sentry_debug { ($($arg:tt)*) => { $crate::Hub::with(|hub| { @@ -64,6 +65,16 @@ macro_rules! sentry_debug { } } +/// Replace the exported macro with a no-op macro when debug_logs is disabled. +#[macro_export] +#[doc(hidden)] +#[cfg(not(feature = "debug_logs"))] +macro_rules! sentry_debug { + ($($arg:tt)*) => { + (); + }; +} + #[allow(unused_macros)] macro_rules! minimal_unreachable { () => { diff --git a/sentry-log/src/lib.rs b/sentry-log/src/lib.rs index a01e8479..bd13ebae 100644 --- a/sentry-log/src/lib.rs +++ b/sentry-log/src/lib.rs @@ -54,7 +54,10 @@ //! //! let logger = sentry_log::SentryLogger::new().filter(|md| match md.level() { //! log::Level::Error => LogFilter::Event, +//! #[cfg(feature = "logs")] //! log::Level::Warn => LogFilter::Breadcrumb | LogFilter::Log, +//! #[cfg(not(feature = "logs"))] +//! log::Level::Warn => LogFilter::Breadcrumb, //! _ => LogFilter::Ignore, //! }); //! ``` diff --git a/sentry/Cargo.toml b/sentry/Cargo.toml index 225df0c6..beaebc12 100644 --- a/sentry/Cargo.toml +++ b/sentry/Cargo.toml @@ -49,6 +49,7 @@ opentelemetry = ["sentry-opentelemetry"] test = ["sentry-core/test"] release-health = ["sentry-core/release-health", "sentry-actix?/release-health"] logs = ["sentry-core/logs", "sentry-tracing?/logs", "sentry-log?/logs"] +debug_logs = ["sentry-core/debug_logs"] # transports transport = ["reqwest", "native-tls"] reqwest = ["dep:reqwest", "httpdate", "tokio"]