diff --git a/Cargo.toml b/Cargo.toml index bc8a4f0..603f823 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -52,7 +52,7 @@ hashbrown = { version = "0.15", optional = true } parking_lot = { version = "0.12", optional = true } regex = { version = "1.12.3", optional = true } vec64 = { version = "0.4.7" } -log = "0.4.29" +log = { version = "0.4.29", optional = true } [dev-dependencies] criterion = { version = "0.8.2", features = ["html_reports"] } @@ -65,6 +65,9 @@ libc = "0.2" [features] +# Enables logging output via the log crate. When disabled, warnings fall back to eprintln! +log = ["dep:log"] + # Adds parallel iterators via `Rayon` parallel_proc = ["rayon"] @@ -312,6 +315,7 @@ default = [ "large_string", "simd", "select", + "log" ] [package.metadata.cargo-all-features] diff --git a/src/lib.rs b/src/lib.rs index 2a94c4f..77710f3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -262,6 +262,7 @@ pub mod traits { pub mod aliases; pub mod conversions; +pub mod log; pub mod macros; pub mod utils; diff --git a/src/log.rs b/src/log.rs new file mode 100644 index 0000000..b3ef4db --- /dev/null +++ b/src/log.rs @@ -0,0 +1,14 @@ +// Conditional logging support: uses log crate when enabled, eprintln fallback when disabled. + +#[cfg(feature = "log")] +pub use log::warn; + +#[cfg(not(feature = "log"))] +macro_rules! warn_fallback { + ($($arg:tt)*) => { + eprintln!($($arg)*) + }; +} + +#[cfg(not(feature = "log"))] +pub(crate) use warn_fallback as warn; diff --git a/src/structs/buffer.rs b/src/structs/buffer.rs index 7a7d3cc..82b761c 100644 --- a/src/structs/buffer.rs +++ b/src/structs/buffer.rs @@ -81,7 +81,7 @@ use std::fmt::{Display, Formatter}; use std::ops::{Deref, DerefMut, RangeBounds}; use std::{fmt, mem}; -use log::warn; +use crate::log::warn; use crate::Vec64; #[cfg(feature = "lbuffer")] diff --git a/src/structs/table.rs b/src/structs/table.rs index e2d0c6b..d557f7d 100644 --- a/src/structs/table.rs +++ b/src/structs/table.rs @@ -35,7 +35,7 @@ use std::sync::atomic::{AtomicUsize, Ordering}; #[cfg(feature = "cast_arrow")] use arrow::array::RecordBatch; -use log::warn; +use crate::log::warn; #[cfg(feature = "cast_polars")] use polars::frame::DataFrame; #[cfg(feature = "cast_polars")]