diff --git a/src/native/skate3_native_ghost.cpp b/src/native/skate3_native_ghost.cpp index 29ffec0..c7a2b3b 100644 --- a/src/native/skate3_native_ghost.cpp +++ b/src/native/skate3_native_ghost.cpp @@ -228,6 +228,10 @@ std::unordered_map> g_roster_names; std::atomic g_request_rooms{false}; RoomList g_rooms; +// Last room we logged a join for (to log connection transitions, not the +// every-5s re-JOIN HELLOs). Network thread only. +std::string g_last_logged_room; + // Network thread. std::thread g_thread; std::atomic g_stop{false}; @@ -549,6 +553,7 @@ void HandlePacket(const GhostAddr& from, const PacketBuf& p, double now) { g_refused = false; } Peer& peer = from_public ? g_peer_public : g_peer_lan; + const bool was_joined = peer.joined; peer.joined = true; peer.last_hello = now; if (from_public) { @@ -575,9 +580,12 @@ void HandlePacket(const GhostAddr& from, const PacketBuf& p, double now) { } } SetStatusPeer(from); - if (Debug()) { + // Always log connection TRANSITIONS (first join / reconnect / room + // change); the periodic re-JOIN HELLOs are not new connections. + if (!was_joined || g_last_logged_room != std::string(hp.room, hp.room_len)) { REXLOG_INFO("ghost: joined {} room={} roster={}", GhostAddrStr(from).c_str(), std::string(hp.room, hp.room_len).c_str(), hp.roster_count); + g_last_logged_room.assign(hp.room, hp.room_len); } return; } @@ -772,9 +780,7 @@ void GhostNetworkLoop() { if (g_peer_public.joined && now - g_peer_public.last_hello > kHelloTimeoutSec) { g_peer_public.joined = false; g_peer_public.last_join = 0.0; - if (debug) { - REXLOG_INFO("ghost: public relay timed out; reconnecting"); - } + REXLOG_WARN("ghost: relay connection lost; reconnecting"); } }