Skip to content

Commit 62cec93

Browse files
committed
Use now-stable kv feature of log crate
Which means updating to 0.4.21
1 parent 9f4a33a commit 62cec93

File tree

4 files changed

+10
-21
lines changed

4 files changed

+10
-21
lines changed

Cargo.lock

Lines changed: 2 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@ color = ["dep:anstream", "dep:anstyle"]
5252
auto-color = ["color", "anstream/auto"]
5353
humantime = ["dep:humantime"]
5454
regex = ["env_filter/regex"]
55-
unstable-kv = ["log/kv_unstable"]
55+
unstable-kv = ["log/kv"]
5656

5757
[dependencies]
58-
log = { version = "0.4.8", features = ["std"] }
58+
log = { version = "0.4.21", features = ["std"] }
5959
env_filter = { version = "0.1.0", path = "crates/env_filter", default-features = false }
6060
humantime = { version = "2.0.0", optional = true }
6161
anstream = { version = "0.6.11", default-features = false, features = ["wincon"], optional = true }

src/fmt/kv.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use super::WriteStyle;
55
use super::{Formatter, StyledValue};
66
#[cfg(feature = "color")]
77
use anstyle::Style;
8-
use log::kv::{source::Source, Error, Key, Value, Visitor};
8+
use log::kv::{Error, Key, Source, Value, VisitSource};
99

1010
/// Format function for serializing key/value pairs
1111
///
@@ -35,22 +35,20 @@ pub fn hidden_kv_format(_formatter: &mut Formatter, _fields: &dyn Source) -> io:
3535
/// For example: `ip=127.0.0.1 port=123456 path=/example`
3636
pub fn default_kv_format(formatter: &mut Formatter, fields: &dyn Source) -> io::Result<()> {
3737
fields
38-
.visit(&mut DefaultVisitor(formatter))
38+
.visit(&mut DefaultVisitSource(formatter))
3939
.map_err(|e| io::Error::new(io::ErrorKind::Other, e))
4040
}
4141

42-
struct DefaultVisitor<'a>(&'a mut Formatter);
42+
struct DefaultVisitSource<'a>(&'a mut Formatter);
4343

44-
impl<'a, 'kvs> Visitor<'kvs> for DefaultVisitor<'a> {
44+
impl<'a, 'kvs> VisitSource<'kvs> for DefaultVisitSource<'a> {
4545
fn visit_pair(&mut self, key: Key, value: Value<'kvs>) -> Result<(), Error> {
46-
// TODO: add styling
47-
// tracing-subscriber uses italic for the key and dimmed for the =
4846
write!(self.0, " {}={}", self.style_key(key), value)?;
4947
Ok(())
5048
}
5149
}
5250

53-
impl DefaultVisitor<'_> {
51+
impl DefaultVisitSource<'_> {
5452
fn style_key<'k>(&self, text: Key<'k>) -> StyledValue<Key<'k>> {
5553
#[cfg(feature = "color")]
5654
{

src/logger.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ impl Builder {
326326
#[cfg(feature = "unstable-kv")]
327327
pub fn format_key_values<F: 'static>(&mut self, format: F) -> &mut Self
328328
where
329-
F: Fn(&mut Formatter, &dyn log::kv::source::Source) -> io::Result<()> + Sync + Send,
329+
F: Fn(&mut Formatter, &dyn log::kv::Source) -> io::Result<()> + Sync + Send,
330330
{
331331
self.format.kv_format = Some(Box::new(format));
332332
self

0 commit comments

Comments
 (0)