From 670afdcc2afe9d8dc45144735b047296a39a452f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Wo=CC=81jcik?= <3044353+pwojcikdev@users.noreply.github.com> Date: Mon, 29 Jan 2024 16:55:05 +0100 Subject: [PATCH] LOG TRACE FORMAT --- nano/lib/logging.hpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/nano/lib/logging.hpp b/nano/lib/logging.hpp index 4f219a1745..1c7a902b9d 100644 --- a/nano/lib/logging.hpp +++ b/nano/lib/logging.hpp @@ -159,8 +159,19 @@ class logger final { if constexpr (is_tracing_enabled ()) { + debug_assert (detail != nano::log::detail::all); + + // 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::object_streamed_args (global_tracing_config, nano::log::arg{ "event", detail }, std::forward (args)...)); + logger.trace ("{}", + nano::object_streamed_args (global_tracing_config, + nano::log::arg{ "event", to_string (std::make_pair (type, detail)) }, + nano::log::arg{ "time", now_micros }, + std::forward (args)...)); } }