From e15ce2575744bc4b3a3df6f35955165097f0c146 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andr=C3=A9=20Silva?= <andre.beat@gmail.com>
Date: Wed, 13 Feb 2019 14:39:21 +0000
Subject: [PATCH] core: cli: log milliseconds when debug/trace enabled (#1784)

---
 substrate/core/cli/src/lib.rs | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/substrate/core/cli/src/lib.rs b/substrate/core/cli/src/lib.rs
index c39a6d5ae61..e472eebe06a 100644
--- a/substrate/core/cli/src/lib.rs
+++ b/substrate/core/cli/src/lib.rs
@@ -364,7 +364,7 @@ where
 		importing: cli.importing_execution.into(),
 		block_construction: cli.block_construction_execution.into(),
 		other: cli.other_execution.into(),
-	}; 
+	};
 
 	config.roles = role;
 	let client_id = config.client_id();
@@ -650,8 +650,9 @@ fn init_logger(pattern: &str) {
 	let enable_color = isatty;
 
 	builder.format(move |buf, record| {
+		let now = time::now();
 		let timestamp =
-			time::strftime("%Y-%m-%d %H:%M:%S", &time::now())
+			time::strftime("%Y-%m-%d %H:%M:%S", &now)
 				.expect("Error formatting log timestamp");
 
 		let mut output = if log::max_level() <= log::LevelFilter::Info {
@@ -660,6 +661,8 @@ fn init_logger(pattern: &str) {
 			let name = ::std::thread::current()
 				.name()
 				.map_or_else(Default::default, |x| format!("{}", Colour::Blue.bold().paint(x)));
+			let millis = (now.tm_nsec as f32 / 1000000.0).round() as usize;
+			let timestamp = format!("{}.{:03}", timestamp, millis);
 			format!(
 				"{} {} {} {}  {}",
 				Colour::Black.bold().paint(timestamp),
-- 
GitLab