ghost: log connection transitions at info by default
Some checks failed
release / build-linux (push) Has been cancelled
Some checks failed
release / build-linux (push) Has been cancelled
Connection state should be visible in the default logs for beta testers: - 'ghost: joined <relay> room=<code> roster=N' now logs on connection TRANSITIONS (first join, reconnect, room change) instead of being gated behind skate3_ghost_debug (which spams every 5s re-JOIN HELLO). - 'ghost: relay connection lost; reconnecting' logs at warn instead of debug.
This commit is contained in:
parent
e3a9fa0b99
commit
eabb989ff7
1 changed files with 10 additions and 4 deletions
|
|
@ -228,6 +228,10 @@ std::unordered_map<uint32_t, std::array<char, kGhostMaxNameLen>> g_roster_names;
|
||||||
std::atomic<bool> g_request_rooms{false};
|
std::atomic<bool> g_request_rooms{false};
|
||||||
RoomList g_rooms;
|
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.
|
// Network thread.
|
||||||
std::thread g_thread;
|
std::thread g_thread;
|
||||||
std::atomic<bool> g_stop{false};
|
std::atomic<bool> g_stop{false};
|
||||||
|
|
@ -549,6 +553,7 @@ void HandlePacket(const GhostAddr& from, const PacketBuf& p, double now) {
|
||||||
g_refused = false;
|
g_refused = false;
|
||||||
}
|
}
|
||||||
Peer& peer = from_public ? g_peer_public : g_peer_lan;
|
Peer& peer = from_public ? g_peer_public : g_peer_lan;
|
||||||
|
const bool was_joined = peer.joined;
|
||||||
peer.joined = true;
|
peer.joined = true;
|
||||||
peer.last_hello = now;
|
peer.last_hello = now;
|
||||||
if (from_public) {
|
if (from_public) {
|
||||||
|
|
@ -575,9 +580,12 @@ void HandlePacket(const GhostAddr& from, const PacketBuf& p, double now) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SetStatusPeer(from);
|
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(),
|
REXLOG_INFO("ghost: joined {} room={} roster={}", GhostAddrStr(from).c_str(),
|
||||||
std::string(hp.room, hp.room_len).c_str(), hp.roster_count);
|
std::string(hp.room, hp.room_len).c_str(), hp.roster_count);
|
||||||
|
g_last_logged_room.assign(hp.room, hp.room_len);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -772,9 +780,7 @@ void GhostNetworkLoop() {
|
||||||
if (g_peer_public.joined && now - g_peer_public.last_hello > kHelloTimeoutSec) {
|
if (g_peer_public.joined && now - g_peer_public.last_hello > kHelloTimeoutSec) {
|
||||||
g_peer_public.joined = false;
|
g_peer_public.joined = false;
|
||||||
g_peer_public.last_join = 0.0;
|
g_peer_public.last_join = 0.0;
|
||||||
if (debug) {
|
REXLOG_WARN("ghost: relay connection lost; reconnecting");
|
||||||
REXLOG_INFO("ghost: public relay timed out; reconnecting");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue