diff --git a/.vscode/settings.json b/.vscode/settings.json index 9e567fc..c95886c 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,5 +1,5 @@ { - "rust-analyzer.checkOnSave.command": "clippy", + "rust-analyzer.check.overrideCommand": ["cargo", "clippy", "--all-targets", "--all-features", "--message-format=json"], "rust-analyzer.cargo.features": "all", "[rust]": { "editor.defaultFormatter": "rust-lang.rust-analyzer" diff --git a/Cargo.toml b/Cargo.toml index 53d859f..5f933e8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "tinylog" -version = "4.0.0" +version = "4.0.1" license = "MIT" description = "A logger for my personal projects." authors = ["Purpzie"] diff --git a/src/tracing_impl/mod.rs b/src/tracing_impl/mod.rs index 4eb7b0e..9b3f48a 100644 --- a/src/tracing_impl/mod.rs +++ b/src/tracing_impl/mod.rs @@ -5,7 +5,7 @@ use crate::{ util::{with_local_buf, Indented, StringLike}, Logger, PrefixOptions, }; -use std::{io, time::Instant}; +use std::io; use tracing::{ span::{Attributes, Record}, Event, Id, Subscriber, @@ -18,7 +18,6 @@ use std::time::SystemTime; struct SpanData { content: String, prefix_end_index: usize, - timestamp: Instant, } impl Layer for Logger @@ -27,7 +26,6 @@ where { fn on_new_span(&self, attrs: &Attributes, id: &Id, ctx: Context) { let span = ctx.span(id).expect("span missing"); - let timestamp = Instant::now(); let mut content = String::new(); self.write_prefix( @@ -46,7 +44,6 @@ where extensions.insert(SpanData { content, prefix_end_index, - timestamp, }); } @@ -60,10 +57,8 @@ where } fn on_event(&self, event: &Event, ctx: Context) { - let event_timestamp = Instant::now(); #[cfg(feature = "timestamps")] let time = SystemTime::now(); - let color = self.color; with_local_buf(move |mut buf| { buf.clear(); @@ -92,37 +87,6 @@ where i_buf.push_str(prefix); i_buf.indent += 2; - // if at least 1 millisecond has passed, let's print it - let time_passed = event_timestamp - data.timestamp; - const NANOS_PER_MILLISECOND: u32 = 1_000_000; - if time_passed.subsec_nanos() >= NANOS_PER_MILLISECOND - || time_passed.as_secs() > 0 - { - let seconds = time_passed.as_secs(); - let milliseconds = time_passed.subsec_millis(); - - i_buf.push(' '); - if color { - // dim - i_buf.push_str("\x1b[2m"); - } - i_buf.push('('); - if seconds == 0 { - i_buf.push_str(itoa::Buffer::new().format(milliseconds)); - i_buf.push('m'); - } else { - i_buf.push_str( - ryu::Buffer::new() - .format((seconds as f64) + ((milliseconds as f64) / 1000.0)), - ); - } - i_buf.push_str("s ago)"); - if color { - // reset - i_buf.push_str("\x1b[m"); - } - } - let name = span.name(); if !name.is_empty() { i_buf.push('\n');