diff --git a/CHANGELOG.md b/CHANGELOG.md index b0178fe..eb7d9d2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file. ## Unreleased +### Improvements + +* Leverage `log::kv::Key::to_static_str` when possible. + ## [0.30.0] 2026-06-03 ### Breaking changes diff --git a/Cargo.toml b/Cargo.toml index 827c54c..7321fa2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -64,7 +64,7 @@ fasyslog = { version = "1.0.0" } insta = { version = "1.43.2" } jiff = { version = "0.2" } libc = { version = "0.2.162" } -log = { version = "0.4.27", default-features = false } +log = { version = "0.4.31", default-features = false } oneshot = { version = "0.2.1", default-features = false, features = ["std"] } opentelemetry = { version = "0.32.0", default-features = false } opentelemetry-otlp = { version = "0.32.0", default-features = false } diff --git a/bridges/log/src/lib.rs b/bridges/log/src/lib.rs index 960a306..8d704a1 100644 --- a/bridges/log/src/lib.rs +++ b/bridges/log/src/lib.rs @@ -248,7 +248,11 @@ mod kv { pub(super) fn key_value_stage_two<'a>(kvs: &'a KeyValuesStageOne<'a>) -> KeyValuesStageTwo<'a> { let mut new_kvs = Vec::with_capacity(kvs.kvs.len()); for (k, v) in &kvs.kvs { - let k = logforth_core::kv::Key::borrowed(k.0.as_str()); + let k = if let Some(k) = k.0.to_static_str() { + logforth_core::kv::Key::new(k) + } else { + logforth_core::kv::Key::borrowed(k.0.as_str()) + }; let v = match &v.0 { MaybeOwnedValue::Borrowed(v) => v.clone(), MaybeOwnedValue::Owned(s) => logforth_core::kv::Value::str(s.as_str()), @@ -289,8 +293,11 @@ mod kv { key: log::kv::Key<'a>, value: log::kv::Value<'a>, ) -> Result<(), log::kv::Error> { - // TODO(@tisonkun): see https://github.com/rust-lang/log/pull/727 - let key = KeyOwned::new(key.to_string()); + let key = if let Some(key) = key.to_static_str() { + KeyOwned::new(key) + } else { + KeyOwned::new(key.to_string()) + }; if let Some(value) = value_to_value(value) { self.0.push((key, value)); }