Skip to content

Commit

Permalink
CHANNEL LOGGING
Browse files Browse the repository at this point in the history
  • Loading branch information
pwojcikdev committed Mar 12, 2024
1 parent c5679d8 commit 002a09a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions nano/lib/logging.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ auto microseconds (std::chrono::time_point<Clock> time)
{
return std::chrono::duration_cast<std::chrono::microseconds> (time.time_since_epoch ()).count ();
}

template <class Clock>
auto milliseconds_delta (std::chrono::time_point<Clock> time, std::chrono::time_point<Clock> now = Clock::now ())
{
return std::chrono::duration_cast<std::chrono::milliseconds> (time - now).count ();
}
}

namespace nano
Expand Down
6 changes: 6 additions & 0 deletions nano/node/transport/channel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,14 @@ nano::endpoint nano::transport::channel::get_peering_endpoint () const

void nano::transport::channel::operator() (nano::object_stream & obs) const
{
nano::lock_guard<nano::mutex> lk (channel_mutex);

obs.write ("endpoint", get_endpoint ());
obs.write ("peering_endpoint", get_peering_endpoint ());
obs.write ("node_id", get_node_id ().to_node_id ());
obs.write ("alive", alive ());

obs.write ("last_bootstrap_attempt", nano::log::milliseconds_delta (get_last_bootstrap_attempt ()));
obs.write ("last_packet_received", nano::log::milliseconds_delta (get_last_packet_received ()));
obs.write ("last_packet_sent", nano::log::milliseconds_delta (get_last_packet_sent ()));
}

0 comments on commit 002a09a

Please sign in to comment.