From 4b1408fafd416df11f3139f7a833cbaf2eea40db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Wo=CC=81jcik?= <3044353+pwojcikdev@users.noreply.github.com> Date: Mon, 5 Feb 2024 20:54:53 +0100 Subject: [PATCH] Use `nano::log::microseconds` helper --- nano/lib/logging.hpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/nano/lib/logging.hpp b/nano/lib/logging.hpp index 8a77dae27d..1415281ba9 100644 --- a/nano/lib/logging.hpp +++ b/nano/lib/logging.hpp @@ -32,6 +32,12 @@ using logger_id = std::pair; std::string to_string (logger_id); logger_id parse_logger_id (std::string const &); + +template +auto microseconds (std::chrono::time_point time) +{ + return std::chrono::duration_cast (time.time_since_epoch ()).count (); +} } namespace nano @@ -163,14 +169,13 @@ class logger final // Include info about precise time of the event auto now = std::chrono::high_resolution_clock::now (); - auto now_micros = std::chrono::duration_cast (now.time_since_epoch ()).count (); // TODO: Improve code indentation config auto logger = get_logger (type, detail); logger.trace ("{}", nano::streamed_args (global_tracing_config, nano::log::arg{ "event", to_string (std::make_pair (type, detail)) }, - nano::log::arg{ "time", now_micros }, + nano::log::arg{ "time", nano::log::microseconds (now) }, std::forward (args)...)); } }