From 52460f9928541f9d014493d846a5fd0e90f9ba8a Mon Sep 17 00:00:00 2001 From: KodrAus Date: Fri, 16 Feb 2024 15:40:52 +1000 Subject: [PATCH] stabilize the kv features --- .github/workflows/main.yml | 36 ++++++++++++++++++---------------- Cargo.toml | 18 ++++++++++------- README.md | 2 +- benches/value.rs | 2 +- src/__private_api.rs | 20 +++++++++---------- src/kv/error.rs | 4 ++-- src/kv/key.rs | 4 ++-- src/kv/mod.rs | 16 ++++++--------- src/kv/value.rs | 40 +++++++++++++++++++------------------- src/lib.rs | 26 ++++++++++++------------- src/macros.rs | 40 ++++++++++++++++++++------------------ tests/Cargo.toml | 8 ++++---- tests/macros.rs | 30 ++++++++++++++-------------- 13 files changed, 124 insertions(+), 122 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 3fc335e73..3c263a434 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -44,10 +44,10 @@ jobs: - run: cargo test --verbose --all-features - run: cargo test --verbose --features serde - run: cargo test --verbose --features std - - run: cargo test --verbose --features kv_unstable - - run: cargo test --verbose --features kv_unstable_sval - - run: cargo test --verbose --features kv_unstable_serde - - run: cargo test --verbose --features "kv_unstable kv_unstable_std kv_unstable_sval kv_unstable_serde" + - run: cargo test --verbose --features kv + - run: cargo test --verbose --features kv_sval + - run: cargo test --verbose --features kv_serde + - run: cargo test --verbose --features "kv kv_std kv_sval kv_serde" - run: cargo run --verbose --manifest-path test_max_level_features/Cargo.toml - run: cargo run --verbose --manifest-path test_max_level_features/Cargo.toml --release @@ -103,12 +103,12 @@ jobs: run: | rustup update nightly --no-self-update rustup default nightly - - run: cargo build --verbose -Z avoid-dev-deps --features kv_unstable - - run: cargo build --verbose -Z avoid-dev-deps --features "kv_unstable std" - - run: cargo build --verbose -Z avoid-dev-deps --features "kv_unstable kv_unstable_sval" - - run: cargo build --verbose -Z avoid-dev-deps --features "kv_unstable kv_unstable_serde" - - run: cargo build --verbose -Z avoid-dev-deps --features "kv_unstable kv_unstable_std" - - run: cargo build --verbose -Z avoid-dev-deps --features "kv_unstable kv_unstable_sval kv_unstable_serde" + - run: cargo build --verbose -Z avoid-dev-deps --features kv + - run: cargo build --verbose -Z avoid-dev-deps --features "kv std" + - run: cargo build --verbose -Z avoid-dev-deps --features "kv kv_sval" + - run: cargo build --verbose -Z avoid-dev-deps --features "kv kv_serde" + - run: cargo build --verbose -Z avoid-dev-deps --features "kv kv_std" + - run: cargo build --verbose -Z avoid-dev-deps --features "kv kv_sval kv_serde" minimalv: name: Minimal versions @@ -119,12 +119,12 @@ jobs: run: | rustup update nightly --no-self-update rustup default nightly - - run: cargo build --verbose -Z minimal-versions --features kv_unstable - - run: cargo build --verbose -Z minimal-versions --features "kv_unstable std" - - run: cargo build --verbose -Z minimal-versions --features "kv_unstable kv_unstable_sval" - - run: cargo build --verbose -Z minimal-versions --features "kv_unstable kv_unstable_serde" - - run: cargo build --verbose -Z minimal-versions --features "kv_unstable kv_unstable_std" - - run: cargo build --verbose -Z minimal-versions --features "kv_unstable kv_unstable_sval kv_unstable_serde" + - run: cargo build --verbose -Z minimal-versions --features kv + - run: cargo build --verbose -Z minimal-versions --features "kv std" + - run: cargo build --verbose -Z minimal-versions --features "kv kv_sval" + - run: cargo build --verbose -Z minimal-versions --features "kv kv_serde" + - run: cargo build --verbose -Z minimal-versions --features "kv kv_std" + - run: cargo build --verbose -Z minimal-versions --features "kv kv_sval kv_serde" msrv: name: MSRV @@ -135,7 +135,9 @@ jobs: run: | rustup update 1.60.0 --no-self-update rustup default 1.60.0 - - run: cargo test --verbose --manifest-path tests/Cargo.toml + - run: | + cargo test --verbose --manifest-path tests/Cargo.toml + cargo test --verbose --manifest-path tests/Cargo.toml --features kv embedded: name: Embedded diff --git a/Cargo.toml b/Cargo.toml index c30944c56..5992d0a9e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,7 +17,7 @@ rust-version = "1.60.0" edition = "2021" [package.metadata.docs.rs] -features = ["std", "serde", "kv_unstable_std", "kv_unstable_sval", "kv_unstable_serde"] +features = ["std", "serde", "kv_std", "kv_sval", "kv_serde"] [[test]] name = "filters" @@ -46,12 +46,16 @@ release_max_level_trace = [] std = [] -# requires the latest stable -# this will have a tighter MSRV before stabilization -kv_unstable = [] -kv_unstable_sval = ["kv_unstable", "value-bag/sval", "sval", "sval_ref"] -kv_unstable_std = ["std", "kv_unstable", "value-bag/error"] -kv_unstable_serde = ["kv_unstable_std", "value-bag/serde", "serde"] +kv = [] +kv_sval = ["kv", "value-bag/sval", "sval", "sval_ref"] +kv_std = ["std", "kv", "value-bag/error"] +kv_serde = ["kv_std", "value-bag/serde", "serde"] + +# Legacy: use `kv_*` instead +kv_unstable = ["kv"] +kv_unstable_sval = ["kv_sval"] +kv_unstable_std = ["kv_std"] +kv_unstable_serde = ["kv_serde"] [dependencies] serde = { version = "1.0", optional = true, default-features = false } diff --git a/README.md b/README.md index 7b188719f..01fd30875 100644 --- a/README.md +++ b/README.md @@ -100,7 +100,7 @@ The executable itself may use the `log` crate to log as well. ## Structured logging -If you enable the `kv_unstable` feature, you can associate structured data with your log records: +If you enable the `kv` feature, you can associate structured data with your log records: ```rust use log::{info, trace, warn}; diff --git a/benches/value.rs b/benches/value.rs index e43be50f7..3d0f18bfe 100644 --- a/benches/value.rs +++ b/benches/value.rs @@ -1,4 +1,4 @@ -#![cfg(feature = "kv_unstable")] +#![cfg(feature = "kv")] #![feature(test)] use log::kv::Value; diff --git a/src/__private_api.rs b/src/__private_api.rs index 5686142c8..fd0a5a762 100644 --- a/src/__private_api.rs +++ b/src/__private_api.rs @@ -5,7 +5,7 @@ use crate::{Level, Metadata, Record}; use std::fmt::Arguments; pub use std::{file, format_args, line, module_path, stringify}; -#[cfg(not(feature = "kv_unstable"))] +#[cfg(not(feature = "kv"))] pub type Value<'a> = &'a str; mod sealed { @@ -40,11 +40,9 @@ fn log_impl( line: u32, kvs: Option<&[(&str, Value)]>, ) { - #[cfg(not(feature = "kv_unstable"))] + #[cfg(not(feature = "kv"))] if kvs.is_some() { - panic!( - "key-value support is experimental and must be enabled using the `kv_unstable` feature" - ) + panic!("key-value support is experimental and must be enabled using the `kv` feature") } let mut builder = Record::builder(); @@ -57,7 +55,7 @@ fn log_impl( .file_static(Some(file)) .line(Some(line)); - #[cfg(feature = "kv_unstable")] + #[cfg(feature = "kv")] builder.key_values(&kvs); crate::logger().log(&builder.build()); @@ -85,7 +83,7 @@ pub fn enabled(level: Level, target: &str) -> bool { crate::logger().enabled(&Metadata::builder().level(level).target(target).build()) } -#[cfg(feature = "kv_unstable")] +#[cfg(feature = "kv")] mod kv_support { use crate::kv; @@ -107,21 +105,21 @@ mod kv_support { Value::from_display(v) } - #[cfg(feature = "kv_unstable_std")] + #[cfg(feature = "kv_std")] pub fn capture_error<'a>(v: &'a (dyn std::error::Error + 'static)) -> Value<'a> { Value::from_dyn_error(v) } - #[cfg(feature = "kv_unstable_sval")] + #[cfg(feature = "kv_sval")] pub fn capture_sval<'a, V: sval::Value + ?Sized>(v: &'a &'a V) -> Value<'a> { Value::from_sval(v) } - #[cfg(feature = "kv_unstable_serde")] + #[cfg(feature = "kv_serde")] pub fn capture_serde<'a, V: serde::Serialize + ?Sized>(v: &'a &'a V) -> Value<'a> { Value::from_serde(v) } } -#[cfg(feature = "kv_unstable")] +#[cfg(feature = "kv")] pub use self::kv_support::*; diff --git a/src/kv/error.rs b/src/kv/error.rs index d654be780..7efa5af36 100644 --- a/src/kv/error.rs +++ b/src/kv/error.rs @@ -37,9 +37,9 @@ impl Error { pub(super) fn into_value(self) -> crate::kv::value::inner::Error { match self.inner { Inner::Value(err) => err, - #[cfg(feature = "kv_unstable_std")] + #[cfg(feature = "kv_std")] _ => crate::kv::value::inner::Error::boxed(self), - #[cfg(not(feature = "kv_unstable_std"))] + #[cfg(not(feature = "kv_std"))] _ => crate::kv::value::inner::Error::msg("error inspecting a value"), } } diff --git a/src/kv/key.rs b/src/kv/key.rs index fb58008c8..9a64b956f 100644 --- a/src/kv/key.rs +++ b/src/kv/key.rs @@ -93,7 +93,7 @@ mod std_support { } } -#[cfg(feature = "kv_unstable_sval")] +#[cfg(feature = "kv_sval")] mod sval_support { use super::*; @@ -116,7 +116,7 @@ mod sval_support { } } -#[cfg(feature = "kv_unstable_serde")] +#[cfg(feature = "kv_serde")] mod serde_support { use super::*; diff --git a/src/kv/mod.rs b/src/kv/mod.rs index 84d392cd4..44f7b06df 100644 --- a/src/kv/mod.rs +++ b/src/kv/mod.rs @@ -1,15 +1,11 @@ -//! **UNSTABLE:** Structured logging. +//! Structured logging. //! -//! This module is unstable and breaking changes may be made -//! at any time. See [the tracking issue](https://github.com/rust-lang-nursery/log/issues/328) -//! for more details. -//! -//! Add the `kv_unstable` feature to your `Cargo.toml` to enable +//! Add the `kv` feature to your `Cargo.toml` to enable //! this module: //! //! ```toml //! [dependencies.log] -//! features = ["kv_unstable"] +//! features = ["kv"] //! ``` //! //! # Structured logging in `log` @@ -48,9 +44,9 @@ //! - `:debug` will capture the value using `Debug`. //! - `:%` will capture the value using `Display`. //! - `:display` will capture the value using `Display`. -//! - `:error` will capture the value using `std::error::Error` (requires the `kv_unstable_std` feature). -//! - `:sval` will capture the value using `sval::Value` (requires the `kv_unstable_sval` feature). -//! - `:serde` will capture the value using `serde::Serialize` (requires the `kv_unstable_serde` feature). +//! - `:error` will capture the value using `std::error::Error` (requires the `kv_std` feature). +//! - `:sval` will capture the value using `sval::Value` (requires the `kv_sval` feature). +//! - `:serde` will capture the value using `serde::Serialize` (requires the `kv_serde` feature). //! //! ## Working with key-values on log records //! diff --git a/src/kv/value.rs b/src/kv/value.rs index 2e0d423e6..6bfff4e4e 100644 --- a/src/kv/value.rs +++ b/src/kv/value.rs @@ -105,8 +105,8 @@ impl<'v> ToValue for Value<'v> { /// supported (see the [`VisitValue`] trait methods). /// /// For more complex types one of the following traits can be used: -/// * `sval::Value`, requires the `kv_unstable_sval` feature. -/// * `serde::Serialize`, requires the `kv_unstable_serde` feature. +/// * `sval::Value`, requires the `kv_sval` feature. +/// * `serde::Serialize`, requires the `kv_serde` feature. /// /// You don't need a visitor to serialize values through `serde` or `sval`. /// @@ -149,7 +149,7 @@ impl<'v> Value<'v> { } /// Get a value from a type implementing `serde::Serialize`. - #[cfg(feature = "kv_unstable_serde")] + #[cfg(feature = "kv_serde")] pub fn from_serde(value: &'v T) -> Self where T: serde::Serialize, @@ -160,7 +160,7 @@ impl<'v> Value<'v> { } /// Get a value from a type implementing `sval::Value`. - #[cfg(feature = "kv_unstable_sval")] + #[cfg(feature = "kv_sval")] pub fn from_sval(value: &'v T) -> Self where T: sval::Value, @@ -185,7 +185,7 @@ impl<'v> Value<'v> { } /// Get a value from a dynamic error. - #[cfg(feature = "kv_unstable_std")] + #[cfg(feature = "kv_std")] pub fn from_dyn_error(err: &'v (dyn std::error::Error + 'static)) -> Self { Value { inner: inner::Inner::from_dyn_error(err), @@ -211,7 +211,7 @@ impl<'v> Value<'v> { /// Inspect this value using a simple visitor. /// - /// When the `kv_unstable_serde` or `kv_unstable_sval` features are enabled, you can also + /// When the `kv_serde` or `kv_sval` features are enabled, you can also /// serialize a value using its `Serialize` or `Value` implementation. pub fn visit(&self, visitor: impl VisitValue<'v>) -> Result<(), Error> { inner::visit(&self.inner, visitor) @@ -230,7 +230,7 @@ impl<'v> fmt::Display for Value<'v> { } } -#[cfg(feature = "kv_unstable_serde")] +#[cfg(feature = "kv_serde")] impl<'v> serde::Serialize for Value<'v> { fn serialize(&self, s: S) -> Result where @@ -240,14 +240,14 @@ impl<'v> serde::Serialize for Value<'v> { } } -#[cfg(feature = "kv_unstable_sval")] +#[cfg(feature = "kv_sval")] impl<'v> sval::Value for Value<'v> { fn stream<'sval, S: sval::Stream<'sval> + ?Sized>(&'sval self, stream: &mut S) -> sval::Result { sval::Value::stream(&self.inner, stream) } } -#[cfg(feature = "kv_unstable_sval")] +#[cfg(feature = "kv_sval")] impl<'v> sval_ref::ValueRef<'v> for Value<'v> { fn stream_ref + ?Sized>(&self, stream: &mut S) -> sval::Result { sval_ref::ValueRef::stream_ref(&self.inner, stream) @@ -362,7 +362,7 @@ impl_value_to_primitive![ impl<'v> Value<'v> { /// Try convert this value into an error. - #[cfg(feature = "kv_unstable_std")] + #[cfg(feature = "kv_std")] pub fn to_borrowed_error(&self) -> Option<&(dyn std::error::Error + 'static)> { self.inner.to_borrowed_error() } @@ -373,7 +373,7 @@ impl<'v> Value<'v> { } } -#[cfg(feature = "kv_unstable_std")] +#[cfg(feature = "kv_std")] mod std_support { use std::borrow::Cow; use std::rc::Rc; @@ -507,13 +507,13 @@ pub trait VisitValue<'v> { } /// Visit an error. - #[cfg(feature = "kv_unstable_std")] + #[cfg(feature = "kv_std")] fn visit_error(&mut self, err: &(dyn std::error::Error + 'static)) -> Result<(), Error> { self.visit_any(Value::from_dyn_error(err)) } /// Visit an error. - #[cfg(feature = "kv_unstable_std")] + #[cfg(feature = "kv_std")] fn visit_borrowed_error( &mut self, err: &'v (dyn std::error::Error + 'static), @@ -570,12 +570,12 @@ where (**self).visit_char(value) } - #[cfg(feature = "kv_unstable_std")] + #[cfg(feature = "kv_std")] fn visit_error(&mut self, err: &(dyn std::error::Error + 'static)) -> Result<(), Error> { (**self).visit_error(err) } - #[cfg(feature = "kv_unstable_std")] + #[cfg(feature = "kv_std")] fn visit_borrowed_error( &mut self, err: &'v (dyn std::error::Error + 'static), @@ -676,7 +676,7 @@ pub(in crate::kv) mod inner { .map_err(crate::kv::Error::into_value) } - #[cfg(feature = "kv_unstable_std")] + #[cfg(feature = "kv_std")] fn visit_error( &mut self, err: &(dyn std::error::Error + 'static), @@ -686,7 +686,7 @@ pub(in crate::kv) mod inner { .map_err(crate::kv::Error::into_value) } - #[cfg(feature = "kv_unstable_std")] + #[cfg(feature = "kv_std")] fn visit_borrowed_error( &mut self, err: &'v (dyn std::error::Error + 'static), @@ -1158,7 +1158,7 @@ pub(crate) mod tests { for v in str() { assert!(v.to_borrowed_str().is_some()); - #[cfg(feature = "kv_unstable_std")] + #[cfg(feature = "kv_std")] assert!(v.to_cow_str().is_some()); } @@ -1167,13 +1167,13 @@ pub(crate) mod tests { assert!(v.to_borrowed_str().is_some()); - #[cfg(feature = "kv_unstable_std")] + #[cfg(feature = "kv_std")] assert!(v.to_cow_str().is_some()); for v in unsigned().chain(signed()).chain(float()).chain(bool()) { assert!(v.to_borrowed_str().is_none()); - #[cfg(feature = "kv_unstable_std")] + #[cfg(feature = "kv_std")] assert!(v.to_cow_str().is_none()); } } diff --git a/src/lib.rs b/src/lib.rs index 8abbfcb2e..feb14e115 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -88,7 +88,7 @@ //! //! ## Structured logging //! -//! If you enable the `kv_unstable` feature you can associate structured values +//! If you enable the `kv` feature you can associate structured values //! with your log records. If we take the example from before, we can include //! some additional context besides what's in the formatted message: //! @@ -97,7 +97,7 @@ //! # #[derive(Debug, Serialize)] pub struct Yak(String); //! # impl Yak { fn shave(&mut self, _: u32) {} } //! # fn find_a_razor() -> Result { Ok(1) } -//! # #[cfg(feature = "kv_unstable_serde")] +//! # #[cfg(feature = "kv_serde")] //! # fn main() { //! use log::{info, warn}; //! @@ -118,7 +118,7 @@ //! } //! } //! # } -//! # #[cfg(not(feature = "kv_unstable_serde"))] +//! # #[cfg(not(feature = "kv_serde"))] //! # fn main() {} //! ``` //! @@ -355,7 +355,7 @@ use std::{cmp, fmt, mem}; mod macros; mod serde; -#[cfg(feature = "kv_unstable")] +#[cfg(feature = "kv")] pub mod kv; #[cfg(target_has_atomic = "ptr")] @@ -723,7 +723,7 @@ pub struct Record<'a> { module_path: Option>, file: Option>, line: Option, - #[cfg(feature = "kv_unstable")] + #[cfg(feature = "kv")] key_values: KeyValues<'a>, } @@ -731,11 +731,11 @@ pub struct Record<'a> { // `#[derive(Debug)]` on `Record`. It also // provides a useful `Debug` implementation for // the underlying `Source`. -#[cfg(feature = "kv_unstable")] +#[cfg(feature = "kv")] #[derive(Clone)] struct KeyValues<'a>(&'a dyn kv::Source); -#[cfg(feature = "kv_unstable")] +#[cfg(feature = "kv")] impl<'a> fmt::Debug for KeyValues<'a> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { let mut visitor = f.debug_map(); @@ -812,14 +812,14 @@ impl<'a> Record<'a> { } /// The structured key-value pairs associated with the message. - #[cfg(feature = "kv_unstable")] + #[cfg(feature = "kv")] #[inline] pub fn key_values(&self) -> &dyn kv::Source { self.key_values.0 } /// Create a new [`RecordBuilder`](struct.RecordBuilder.html) based on this record. - #[cfg(feature = "kv_unstable")] + #[cfg(feature = "kv")] #[inline] pub fn to_builder(&self) -> RecordBuilder { RecordBuilder { @@ -904,7 +904,7 @@ impl<'a> RecordBuilder<'a> { module_path: None, file: None, line: None, - #[cfg(feature = "kv_unstable")] + #[cfg(feature = "kv")] key_values: KeyValues(&None::<(kv::Key, kv::Value)>), }, } @@ -974,7 +974,7 @@ impl<'a> RecordBuilder<'a> { } /// Set [`key_values`](struct.Record.html#method.key_values) - #[cfg(feature = "kv_unstable")] + #[cfg(feature = "kv")] #[inline] pub fn key_values(&mut self, kvs: &'a dyn kv::Source) -> &mut RecordBuilder<'a> { self.record.key_values = KeyValues(kvs); @@ -1757,7 +1757,7 @@ mod tests { } #[test] - #[cfg(feature = "kv_unstable")] + #[cfg(feature = "kv")] fn test_record_key_values_builder() { use super::Record; use crate::kv::{self, VisitSource}; @@ -1788,7 +1788,7 @@ mod tests { } #[test] - #[cfg(feature = "kv_unstable")] + #[cfg(feature = "kv")] fn test_record_key_values_get_coerce() { use super::Record; diff --git a/src/macros.rs b/src/macros.rs index 74de7f892..9ad6e7f08 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -231,7 +231,7 @@ macro_rules! log_enabled { #[doc(hidden)] #[macro_export] -#[cfg(feature = "kv_unstable")] +#[cfg(feature = "kv")] macro_rules! __log_key { // key1 = 42 ($($args:ident)*) => { @@ -245,16 +245,16 @@ macro_rules! __log_key { #[doc(hidden)] #[macro_export] -#[cfg(not(feature = "kv_unstable"))] +#[cfg(not(feature = "kv"))] macro_rules! __log_key { ($($args:tt)*) => { - compile_error!("key value support requires the `kv_unstable` feature of `log`") + compile_error!("key value support requires the `kv` feature of `log`") }; } #[doc(hidden)] #[macro_export] -#[cfg(feature = "kv_unstable")] +#[cfg(feature = "kv")] macro_rules! __log_value { // Default (($args:expr)) => { @@ -294,25 +294,27 @@ macro_rules! __log_value { #[doc(hidden)] #[macro_export] -#[cfg(not(feature = "kv_unstable"))] +#[cfg(not(feature = "kv"))] macro_rules! __log_value { ($($args:tt)*) => { - compile_error!("key value support requires the `kv_unstable` feature of `log`") + compile_error!("key value support requires the `kv` feature of `log`") }; } #[doc(hidden)] #[macro_export] -#[cfg(not(feature = "kv_unstable_std"))] +#[cfg(not(feature = "kv_std"))] macro_rules! __log_value_error { ($args:expr) => { - compile_error!("capturing values as `std::error::Error` requites the `kv_unstable_std` feature of `log`") - } + compile_error!( + "capturing values as `std::error::Error` requites the `kv_std` feature of `log`" + ) + }; } #[doc(hidden)] #[macro_export] -#[cfg(feature = "kv_unstable_sval")] +#[cfg(feature = "kv_sval")] macro_rules! __log_value_sval { ($args:expr) => { $crate::__private_api::capture_sval(&&$args) @@ -321,18 +323,16 @@ macro_rules! __log_value_sval { #[doc(hidden)] #[macro_export] -#[cfg(not(feature = "kv_unstable_sval"))] +#[cfg(not(feature = "kv_sval"))] macro_rules! __log_value_sval { ($args:expr) => { - compile_error!( - "capturing values as `sval::Value` requites the `kv_unstable_sval` feature of `log`" - ) + compile_error!("capturing values as `sval::Value` requites the `kv_sval` feature of `log`") }; } #[doc(hidden)] #[macro_export] -#[cfg(feature = "kv_unstable_serde")] +#[cfg(feature = "kv_serde")] macro_rules! __log_value_serde { ($args:expr) => { $crate::__private_api::capture_serde(&&$args) @@ -341,16 +341,18 @@ macro_rules! __log_value_serde { #[doc(hidden)] #[macro_export] -#[cfg(not(feature = "kv_unstable_serde"))] +#[cfg(not(feature = "kv_serde"))] macro_rules! __log_value_serde { ($args:expr) => { - compile_error!("capturing values as `serde::Serialize` requites the `kv_unstable_serde` feature of `log`") - } + compile_error!( + "capturing values as `serde::Serialize` requites the `kv_serde` feature of `log`" + ) + }; } #[doc(hidden)] #[macro_export] -#[cfg(feature = "kv_unstable_std")] +#[cfg(feature = "kv_std")] macro_rules! __log_value_error { ($args:expr) => { $crate::__private_api::capture_error(&$args) diff --git a/tests/Cargo.toml b/tests/Cargo.toml index 7d0d3e853..8754bb16a 100644 --- a/tests/Cargo.toml +++ b/tests/Cargo.toml @@ -7,10 +7,10 @@ build = "src/build.rs" [features] std = ["log/std"] -kv_unstable = ["log/kv_unstable"] -kv_unstable_std = ["log/kv_unstable_std"] -kv_unstable_sval = ["log/kv_unstable_sval"] -kv_unstable_serde = ["log/kv_unstable_serde"] +kv = ["log/kv"] +kv_std = ["log/kv_std"] +kv_sval = ["log/kv_sval"] +kv_serde = ["log/kv_serde"] [dependencies.log] path = ".." diff --git a/tests/macros.rs b/tests/macros.rs index 47cc957d9..07bdf53f0 100644 --- a/tests/macros.rs +++ b/tests/macros.rs @@ -107,7 +107,7 @@ fn expr() { } #[test] -#[cfg(feature = "kv_unstable")] +#[cfg(feature = "kv")] fn kv_no_args() { for lvl in log::Level::iter() { log!(target: "my_target", lvl, cat_1 = "chashu", cat_2 = "nori", cat_count = 2; "hello"); @@ -121,7 +121,7 @@ fn kv_no_args() { } #[test] -#[cfg(feature = "kv_unstable")] +#[cfg(feature = "kv")] fn kv_expr_args() { for lvl in log::Level::iter() { log!(target: "my_target", lvl, cat_math = { let mut x = 0; x += 1; x + 1 }; "hello"); @@ -136,7 +136,7 @@ fn kv_expr_args() { } #[test] -#[cfg(feature = "kv_unstable")] +#[cfg(feature = "kv")] fn kv_anonymous_args() { for lvl in log::Level::iter() { log!(target: "my_target", lvl, cat_1 = "chashu", cat_2 = "nori", cat_count = 2; "hello {}", "world"); @@ -151,7 +151,7 @@ fn kv_anonymous_args() { } #[test] -#[cfg(feature = "kv_unstable")] +#[cfg(feature = "kv")] fn kv_named_args() { for lvl in log::Level::iter() { log!(target: "my_target", lvl, cat_1 = "chashu", cat_2 = "nori", cat_count = 2; "hello {world}", world = "world"); @@ -166,7 +166,7 @@ fn kv_named_args() { } #[test] -#[cfg(feature = "kv_unstable")] +#[cfg(feature = "kv")] fn kv_expr_context() { match "chashu" { cat_1 => { @@ -196,14 +196,14 @@ fn implicit_named_args() { all_log_macros!(target: "my_target", "hello {world}"); all_log_macros!(target: "my_target", "hello {world}",); - #[cfg(feature = "kv_unstable")] + #[cfg(feature = "kv")] all_log_macros!(target = "my_target"; "hello {world}"); - #[cfg(feature = "kv_unstable")] + #[cfg(feature = "kv")] all_log_macros!(target = "my_target"; "hello {world}",); } #[test] -#[cfg(feature = "kv_unstable")] +#[cfg(feature = "kv")] fn kv_implicit_named_args() { let world = "world"; @@ -219,7 +219,7 @@ fn kv_implicit_named_args() { } #[test] -#[cfg(feature = "kv_unstable")] +#[cfg(feature = "kv")] fn kv_string_keys() { for lvl in log::Level::iter() { log!(target: "my_target", lvl, "also dogs" = "FĂ­los", "key/that-can't/be/an/ident" = "hi"; "hello {world}", world = "world"); @@ -229,7 +229,7 @@ fn kv_string_keys() { } #[test] -#[cfg(feature = "kv_unstable")] +#[cfg(feature = "kv")] fn kv_common_value_types() { all_log_macros!( u8 = 42u8, @@ -251,7 +251,7 @@ fn kv_common_value_types() { } #[test] -#[cfg(feature = "kv_unstable")] +#[cfg(feature = "kv")] fn kv_debug() { all_log_macros!( a:? = 42, @@ -261,7 +261,7 @@ fn kv_debug() { } #[test] -#[cfg(feature = "kv_unstable")] +#[cfg(feature = "kv")] fn kv_display() { all_log_macros!( a:% = 42, @@ -271,7 +271,7 @@ fn kv_display() { } #[test] -#[cfg(feature = "kv_unstable_std")] +#[cfg(feature = "kv_std")] fn kv_error() { all_log_macros!( a:error = std::io::Error::new(std::io::ErrorKind::Other, "an error"); @@ -280,7 +280,7 @@ fn kv_error() { } #[test] -#[cfg(feature = "kv_unstable_sval")] +#[cfg(feature = "kv_sval")] fn kv_sval() { all_log_macros!( a:sval = 42; @@ -289,7 +289,7 @@ fn kv_sval() { } #[test] -#[cfg(feature = "kv_unstable_serde")] +#[cfg(feature = "kv_serde")] fn kv_serde() { all_log_macros!( a:serde = 42;