Improved log processing by adding index logging, client count logging, and client address logging when sending events.

This commit is contained in:
Benjamin Arntzen (aider)
2024-06-27 06:42:59 +01:00
parent 2c7c2af3e2
commit a5a4e0d1f6
+6 -1
View File
@@ -67,7 +67,8 @@ setInterval(async () => {
logs = validLogs;
if (Array.isArray(logs)) {
console.log('Processing logs array');
logs.forEach(log => {
logs.forEach((log, index) => {
console.log(`Processing log at index ${index}:`, log);
const msgMatch = log._msg.match(/msg_hash=0x[0-9a-fA-F]+/);
const timeMatch = log._msg.match(/receivedTime=\d+/);
const nodeIdMatch = log.kubernetes_pod_name.match(/nodes-(\d+)/);
@@ -95,8 +96,12 @@ setInterval(async () => {
} else {
console.log(`Sending "light up node ${logData.nodeId}" event to clients`);
}
console.log('Number of connected clients:', wss.clients.size);
wss.clients.forEach(client => {
if (client.readyState === WebSocket.OPEN) {
console.log(`Sending event to client ${client._socket.remoteAddress}`);
client.send(JSON.stringify(logData));
}
});