Skip to content

Commit

Permalink
chore: Remove unnecessary Chrono dependency (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
matklad authored Feb 22, 2021
1 parent f0bceec commit 5edea45
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ tracing = "0.1"
tracing-subscriber = { version = "0.2", default-features = false, features = ["registry", "fmt"] }
termcolor = "1.1"
ansi_term = "0.12"
chrono = "0.4"
atty = "0.2"
tracing-log = { version = "0.1", optional = true }

Expand Down
14 changes: 5 additions & 9 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
pub(crate) mod format;

use ansi_term::{Color, Style};
use chrono::{DateTime, Local};
use format::{Buffers, ColorLevel, Config, FmtEvent, SpanMode};
use std::{
fmt::{self, Write as _},
io,
sync::Mutex,
time::Instant,
};
use tracing::{
field::{Field, Visit},
Expand All @@ -22,14 +22,14 @@ use tracing_subscriber::{
};

pub(crate) struct Data {
start: DateTime<Local>,
start: Instant,
kvs: Vec<(&'static str, String)>,
}

impl Data {
pub fn new(attrs: &tracing::span::Attributes<'_>) -> Self {
let mut span = Self {
start: Local::now(),
start: Instant::now(),
kvs: Vec::new(),
};
attrs.record(&mut span);
Expand Down Expand Up @@ -322,16 +322,12 @@ where
},
None => None,
};
let now = Local::now();
if let Some(start) = start {
let elapsed = now - start;
let elapsed = start.elapsed();
write!(
&mut event_buf,
"{timestamp}{unit} ",
timestamp = self.styled(
Style::new().dimmed(),
elapsed.num_milliseconds().to_string()
),
timestamp = self.styled(Style::new().dimmed(), elapsed.as_millis().to_string()),
unit = self.styled(Style::new().dimmed(), "ms"),
)
.expect("Unable to write to buffer");
Expand Down

0 comments on commit 5edea45

Please sign in to comment.