diff --git a/components/icu/Cargo.toml b/components/icu/Cargo.toml index 211f3f3d6ad..73f0a821487 100644 --- a/components/icu/Cargo.toml +++ b/components/icu/Cargo.toml @@ -49,7 +49,7 @@ icu_compactdecimal = { version = "0.2.0", path = "../../experimental/compactdeci icu_displaynames = { version = "0.10.0", path = "../../experimental/displaynames", default-features = false, optional = true } icu_relativetime = { version = "0.1.0", path = "../../experimental/relativetime", default-features = false, optional = true } -# For docs links +# For docs links and features icu_provider = { version = "1.2.0", path = "../../provider/core", default-features = false } [dev-dependencies] @@ -141,6 +141,8 @@ experimental = [ "icu_plurals/experimental", "icu_relativetime", ] +sync = ["icu_provider/sync"] +logging = ["icu_provider/logging"] [package.metadata.cargo-all-features] # Components are tested individually, and there's no logic in this crate diff --git a/ffi/diplomat/Cargo.toml b/ffi/diplomat/Cargo.toml index 9af0756fe8e..d753ac81e17 100644 --- a/ffi/diplomat/Cargo.toml +++ b/ffi/diplomat/Cargo.toml @@ -61,7 +61,7 @@ buffer_provider = [ ] provider_fs = ["dep:icu_provider_fs", "buffer_provider"] provider_test = [] -logging = ["icu_provider/log_error_context", "dep:log"] +logging = ["icu_provider/logging", "dep:log"] # Use the env_logger functionality to log based on environment variables simple_logger = ["dep:simple_logger"] diff --git a/provider/core/Cargo.toml b/provider/core/Cargo.toml index de8da5ec467..1f0529cf443 100644 --- a/provider/core/Cargo.toml +++ b/provider/core/Cargo.toml @@ -63,7 +63,9 @@ sync = [] macros = ["dep:icu_provider_macros"] # Enable logging of additional context of data errors -log_error_context = ["dep:log"] +logging = ["dep:log"] +# Legacy name +log_error_context = ["logging"] # Enable BufferProvider and other deserialization infrastructure serde = ["dep:serde", "yoke/serde"] diff --git a/provider/core/src/error.rs b/provider/core/src/error.rs index 23f141e0244..e740f87aa97 100644 --- a/provider/core/src/error.rs +++ b/provider/core/src/error.rs @@ -203,15 +203,15 @@ impl DataError { /// Logs the data error with the given request, returning an error containing the resource key. /// - /// If the "log_error_context" Cargo feature is enabled, this logs the whole request. Either way, + /// If the "logging" Cargo feature is enabled, this logs the whole request. Either way, /// it returns an error with the resource key portion of the request as context. - #[cfg_attr(not(feature = "log_error_context"), allow(unused_variables))] + #[cfg_attr(not(feature = "logging"), allow(unused_variables))] pub fn with_req(mut self, key: DataKey, req: DataRequest) -> Self { if req.metadata.silent { self.silent = true; } // Don't write out a log for MissingDataKey since there is no context to add - #[cfg(feature = "log_error_context")] + #[cfg(feature = "logging")] if !self.silent && self.kind != DataErrorKind::MissingDataKey { log::warn!("{} (key: {}, request: {})", self, key, req); } @@ -220,12 +220,12 @@ impl DataError { /// Logs the data error with the given context, then return self. /// - /// This does not modify the error, but if the "log_error_context" Cargo feature is enabled, + /// This does not modify the error, but if the "logging" Cargo feature is enabled, /// it will print out the context. #[cfg(feature = "std")] - #[cfg_attr(not(feature = "log_error_context"), allow(unused_variables))] + #[cfg_attr(not(feature = "logging"), allow(unused_variables))] pub fn with_path_context + ?Sized>(self, path: &P) -> Self { - #[cfg(feature = "log_error_context")] + #[cfg(feature = "logging")] if !self.silent { log::warn!("{} (path: {:?})", self, path.as_ref()); } @@ -234,12 +234,12 @@ impl DataError { /// Logs the data error with the given context, then return self. /// - /// This does not modify the error, but if the "log_error_context" Cargo feature is enabled, + /// This does not modify the error, but if the "logging" Cargo feature is enabled, /// it will print out the context. - #[cfg_attr(not(feature = "log_error_context"), allow(unused_variables))] + #[cfg_attr(not(feature = "logging"), allow(unused_variables))] #[inline] pub fn with_display_context(self, context: &D) -> Self { - #[cfg(feature = "log_error_context")] + #[cfg(feature = "logging")] if !self.silent { log::warn!("{}: {}", self, context); } @@ -248,12 +248,12 @@ impl DataError { /// Logs the data error with the given context, then return self. /// - /// This does not modify the error, but if the "log_error_context" Cargo feature is enabled, + /// This does not modify the error, but if the "logging" Cargo feature is enabled, /// it will print out the context. - #[cfg_attr(not(feature = "log_error_context"), allow(unused_variables))] + #[cfg_attr(not(feature = "logging"), allow(unused_variables))] #[inline] pub fn with_debug_context(self, context: &D) -> Self { - #[cfg(feature = "log_error_context")] + #[cfg(feature = "logging")] if !self.silent { log::warn!("{}: {:?}", self, context); } @@ -277,7 +277,7 @@ impl std::error::Error for DataError {} #[cfg(feature = "std")] impl From for DataError { fn from(e: std::io::Error) -> Self { - #[cfg(feature = "log_error_context")] + #[cfg(feature = "logging")] log::warn!("I/O error: {}", e); DataErrorKind::Io(e.kind()).into_error() } diff --git a/provider/datagen/Cargo.toml b/provider/datagen/Cargo.toml index fb888a54acf..efae52c7702 100644 --- a/provider/datagen/Cargo.toml +++ b/provider/datagen/Cargo.toml @@ -54,7 +54,7 @@ icu_timezone = { version = "1.2.0", path = "../../components/timezone", default- icu_codepointtrie_builder = { version = "0.3.4", path = "../../components/collections/codepointtrie_builder", default-features = false } icu_collections = { version = "1.2.0", path = "../../components/collections", features = ["serde"] } icu_locid = { version = "1.2.0", path = "../../components/locid", features = ["std", "serde"] } -icu_provider = { version = "1.2.0", path = "../core", features = ["std", "log_error_context", "datagen"]} +icu_provider = { version = "1.2.0", path = "../core", features = ["std", "logging", "datagen"]} icu_provider_adapters = { version = "1.2.0", path = "../adapters" } tinystr = { version = "0.7.1", path = "../../utils/tinystr", features = ["alloc", "serde", "zerovec"], default-features = false } writeable = { version = "0.5.1", path = "../../utils/writeable" }