Skip to content

Commit 5edea45

Browse files
authored
chore: Remove unnecessary Chrono dependency (#30)
1 parent f0bceec commit 5edea45

File tree

2 files changed

+5
-10
lines changed

2 files changed

+5
-10
lines changed

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ tracing = "0.1"
1313
tracing-subscriber = { version = "0.2", default-features = false, features = ["registry", "fmt"] }
1414
termcolor = "1.1"
1515
ansi_term = "0.12"
16-
chrono = "0.4"
1716
atty = "0.2"
1817
tracing-log = { version = "0.1", optional = true }
1918

src/lib.rs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
pub(crate) mod format;
22

33
use ansi_term::{Color, Style};
4-
use chrono::{DateTime, Local};
54
use format::{Buffers, ColorLevel, Config, FmtEvent, SpanMode};
65
use std::{
76
fmt::{self, Write as _},
87
io,
98
sync::Mutex,
9+
time::Instant,
1010
};
1111
use tracing::{
1212
field::{Field, Visit},
@@ -22,14 +22,14 @@ use tracing_subscriber::{
2222
};
2323

2424
pub(crate) struct Data {
25-
start: DateTime<Local>,
25+
start: Instant,
2626
kvs: Vec<(&'static str, String)>,
2727
}
2828

2929
impl Data {
3030
pub fn new(attrs: &tracing::span::Attributes<'_>) -> Self {
3131
let mut span = Self {
32-
start: Local::now(),
32+
start: Instant::now(),
3333
kvs: Vec::new(),
3434
};
3535
attrs.record(&mut span);
@@ -322,16 +322,12 @@ where
322322
},
323323
None => None,
324324
};
325-
let now = Local::now();
326325
if let Some(start) = start {
327-
let elapsed = now - start;
326+
let elapsed = start.elapsed();
328327
write!(
329328
&mut event_buf,
330329
"{timestamp}{unit} ",
331-
timestamp = self.styled(
332-
Style::new().dimmed(),
333-
elapsed.num_milliseconds().to_string()
334-
),
330+
timestamp = self.styled(Style::new().dimmed(), elapsed.as_millis().to_string()),
335331
unit = self.styled(Style::new().dimmed(), "ms"),
336332
)
337333
.expect("Unable to write to buffer");

0 commit comments

Comments
 (0)