Improved log parsing and processing, removed unnecessary console logs.
This commit is contained in:
@@ -38,7 +38,6 @@ setInterval(async () => {
|
||||
}
|
||||
});
|
||||
logs = validLogs;
|
||||
console.log('Parsed logs from logsexample.out:', logs);
|
||||
} catch (error) {
|
||||
console.error('Error reading logsexample.out:', error);
|
||||
return;
|
||||
@@ -52,7 +51,6 @@ setInterval(async () => {
|
||||
'Content-Type': 'application/x-www-form-urlencoded'
|
||||
}
|
||||
});
|
||||
console.log('Received response from vmselect:', response.data);
|
||||
const logLines = response.data.split('\n');
|
||||
const validLogs = [];
|
||||
logLines.forEach((line, index) => {
|
||||
@@ -67,11 +65,9 @@ setInterval(async () => {
|
||||
}
|
||||
});
|
||||
logs = validLogs;
|
||||
console.log('Parsed logs from vmselect response:', logs);
|
||||
if (Array.isArray(logs)) {
|
||||
console.log('Processing logs array');
|
||||
logs.forEach(log => {
|
||||
console.log('Processing log:', 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+)/);
|
||||
@@ -81,7 +77,6 @@ setInterval(async () => {
|
||||
const receivedTime = timeMatch[0].split('=')[1];
|
||||
const nodeId = parseInt(nodeIdMatch[1], 10);
|
||||
|
||||
console.log(`Parsed log - msg_hash: ${msg_hash}, receivedTime: ${receivedTime}, nodeId: ${nodeId}`);
|
||||
|
||||
const logIdentifier = `${msg_hash}-${receivedTime}`;
|
||||
if (!logCache.has(logIdentifier)) {
|
||||
@@ -95,10 +90,13 @@ setInterval(async () => {
|
||||
|
||||
logCache.add(`node-${nodeId}`);
|
||||
|
||||
console.log('Sending log data to clients:', logData);
|
||||
if (logData.newNode) {
|
||||
console.log(`Sending "create node ${logData.nodeId}" event to clients`);
|
||||
} else {
|
||||
console.log(`Sending "light up node ${logData.nodeId}" event to clients`);
|
||||
}
|
||||
wss.clients.forEach(client => {
|
||||
if (client.readyState === WebSocket.OPEN) {
|
||||
console.log('Sending log data to client:', client._socket.remoteAddress);
|
||||
client.send(JSON.stringify(logData));
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user