Skip to content

Commit

Permalink
Use nano::log::microseconds helper
Browse files Browse the repository at this point in the history
  • Loading branch information
pwojcikdev committed Feb 5, 2024
1 parent 3805e36 commit 4b1408f
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions nano/lib/logging.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ using logger_id = std::pair<nano::log::type, nano::log::detail>;

std::string to_string (logger_id);
logger_id parse_logger_id (std::string const &);

template <class Clock>
auto microseconds (std::chrono::time_point<Clock> time)
{
return std::chrono::duration_cast<std::chrono::microseconds> (time.time_since_epoch ()).count ();
}
}

namespace nano
Expand Down Expand Up @@ -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<std::chrono::microseconds> (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> (args)...));
}
}
Expand Down

0 comments on commit 4b1408f

Please sign in to comment.