Implemented a real-time console log streaming via WebSocket for debugging purposes. Users can enable console output in settings to view application logs directly in the web interface.

This commit is contained in:
2026-01-14 21:47:17 +01:00
parent e997059e2a
commit 44da16977c
16 changed files with 501 additions and 15 deletions

View File

@@ -73,6 +73,26 @@ type Hub struct {
mu sync.RWMutex
}
// BroadcastConsoleLog broadcasts a console log message to all connected clients
func (h *Hub) BroadcastConsoleLog(message string) {
logMsg := map[string]interface{}{
"type": "console_log",
"message": message,
"time": time.Now().UTC().Format(time.RFC3339),
}
data, err := json.Marshal(logMsg)
if err != nil {
log.Printf("Error marshaling console log: %v", err)
return
}
select {
case h.broadcast <- data:
default:
// Channel full, drop message
}
}
// NewHub creates a new WebSocket hub
func NewHub() *Hub {
return &Hub{