Update NetworkClient to use log manager and use common name constant in server logs

This commit is contained in:
Adam Honse
2026-01-24 10:07:41 -06:00
parent 276fbd0111
commit 3009d6a08a
2 changed files with 40 additions and 29 deletions

View File

@@ -10,6 +10,7 @@
\*---------------------------------------------------------*/
#include <cstring>
#include "LogManager.h"
#include "NetworkClient.h"
#include "RGBController_Network.h"
#include "StringUtils.h"
@@ -37,6 +38,11 @@ const char yes = 1;
using namespace std::chrono_literals;
/*---------------------------------------------------------*\
| NetworkClient name for log entries |
\*---------------------------------------------------------*/
const char* NETWORKCLIENT = "NetworkClient";
NetworkClient::NetworkClient()
{
port_ip = "127.0.0.1";
@@ -692,7 +698,7 @@ void NetworkClient::ConnectionThreadFunction()
if(port.tcp_client_connect() == true)
{
client_sock = port.sock;
printf( "Connected to server\n" );
LOG_INFO("[%s] Connected to server", NETWORKCLIENT);
/*---------------------------------------------------------*\
| Server is now connected |
@@ -716,7 +722,7 @@ void NetworkClient::ConnectionThreadFunction()
}
else
{
printf( "Connection attempt failed\n" );
LOG_INFO("[%s] Connection attempt failed", NETWORKCLIENT);
}
}
@@ -838,7 +844,7 @@ void NetworkClient::ConnectionThreadFunction()
if(rgb_controller == NULL)
{
printf("Client: Requesting controller ID %d\r\n", server_controller_ids[requested_controller_index]);
LOG_INFO("[%s] Requesting controller ID %d", NETWORKCLIENT, server_controller_ids[requested_controller_index]);
controller_data_received = false;
SendRequest_ControllerData(id);
@@ -881,7 +887,7 @@ void NetworkClient::ConnectionThreadFunction()
void NetworkClient::ListenThreadFunction()
{
printf("Network client listener started\n");
LOG_INFO("[%s] Listener thread started", NETWORKCLIENT);
/*---------------------------------------------------------*\
| This thread handles messages received from the server |
@@ -1029,7 +1035,7 @@ void NetworkClient::ListenThreadFunction()
}
listen_done:
printf( "Client socket has been closed");
LOG_INFO("[%s] Client socket has been closed", NETWORKCLIENT);
client_string_sent = false;
controller_data_requested = false;
controller_data_received = false;
@@ -1158,7 +1164,7 @@ void NetworkClient::ProcessReply_ControllerIDs(unsigned int data_size, char * da
else
{
server_controller_ids.clear();
printf("Client: Received incorrect packet size for controller list, list cleared");
LOG_INFO("[%s] Received incorrect packet size for controller list, list cleared", NETWORKCLIENT);
}
}
/*-------------------------------------------------*\