From ac6518abe5088e55e191f44917f9774e97e48a45 Mon Sep 17 00:00:00 2001 From: Bryan Biedenkapp Date: Wed, 9 Oct 2024 15:26:27 -0400 Subject: [PATCH] fix some issues with not clocking timers for peer list and aff list; fix issue with logging system not redirecting to a std::ostream; --- src/sysview/HostWS.cpp | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/src/sysview/HostWS.cpp b/src/sysview/HostWS.cpp index 07f4f6c1..2a7f1c23 100644 --- a/src/sysview/HostWS.cpp +++ b/src/sysview/HostWS.cpp @@ -149,11 +149,15 @@ int HostWS::run() StopWatch stopWatch; stopWatch.start(); + g_logDisplayLevel = 0U; + std::ostringstream logOutput; __InternalOutputStream(logOutput); Timer peerListUpdate(1000U, 10U); + peerListUpdate.start(); Timer affListUpdate(1000U, 10U); + affListUpdate.start(); // main execution loop while (!g_killed) { @@ -163,17 +167,10 @@ int HostWS::run() stopWatch.start(); if (m_wsConList.size() > 0U) { - if (!peerListUpdate.isRunning()) { - peerListUpdate.start(); - } - - if (!affListUpdate.isRunning()) { - affListUpdate.start(); - } - // send log messages if (!logOutput.str().empty()) { - std::string str = logOutput.str(); + std::string str = std::string(logOutput.str()); + logOutput.str(""); json::object wsObj = json::object(); std::string type = "log"; @@ -194,8 +191,9 @@ int HostWS::run() wsObj["payload"].set(peerStatus); send(wsObj); } - + // update peer list data + peerListUpdate.clock(ms); if (peerListUpdate.isRunning() && peerListUpdate.hasExpired()) { peerListUpdate.start(); // callback REST API to get status of the channel we represent @@ -222,6 +220,7 @@ int HostWS::run() } // update affiliation list data + affListUpdate.clock(ms); if (affListUpdate.isRunning() && affListUpdate.hasExpired()) { affListUpdate.start(); // callback REST API to get status of the channel we represent @@ -247,14 +246,16 @@ int HostWS::run() } } } else { - peerListUpdate.stop(); - affListUpdate.stop(); + // clear ostream + logOutput.str(""); } if (ms < 2U) Thread::sleep(1U); } + g_logDisplayLevel = 1U; + if (g_killed) m_wsServer.stop();