 console.log('Closing log stream connection');
          logSource.close();
          logSource = null;
        }
      }

      function reconnectLogSource() {
        if (logSource) {
            logSource.close();
        }
        console.log('Attempting to reconnect to log stream...');
        setTimeout(() => {
            setupLogSource();
        }, 5000); // Wait 5 seconds before attempting to reconnect
      }

      setupLogSource();

      function addLogEntry(time, method, endpoint, status, dur