From 47beca218e5aef8ccaceec9933a9e99c43640b0b Mon Sep 17 00:00:00 2001 From: Piotr Tabor Date: Sun, 8 Dec 2024 18:05:10 +0100 Subject: [PATCH] More logging. --- http/handlers.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/http/handlers.go b/http/handlers.go index c395a45..5e7b566 100644 --- a/http/handlers.go +++ b/http/handlers.go @@ -339,19 +339,22 @@ func (h *Handler) connectAllInternal(iface string, waitSec string) error { ctx := context.Background() devices := h.discoverDnsEntries(ctx, iface, waitSec) apps := make(chan *application.App, len(devices)+1) - // g, ctx := errgroup.WithContext(ctx) for _, device := range devices { g.Go(func() error { + log.Printf("Connecting to %s:%d (%s)", device.Addr, device.Port, device.DeviceName) app, err := h.connectInternal(device.Addr, device.Port, device.DeviceName) if err != nil { + log.Printf("Connection to %s:%d (%s) failed: %v", device.Addr, device.Port, device.DeviceName, err) return err } + log.Printf("Connected to %s:%d (%s)", device.Addr, device.Port, device.DeviceName) apps <- &app return nil }) } err := g.Wait() + log.Printf("Post wait status: %v", err) close(apps) // Even if we cannot connect to some of the devices, we still update the map for remaining devices. @@ -359,9 +362,10 @@ func (h *Handler) connectAllInternal(iface string, waitSec string) error { for app := range apps { info, err := (*app).Info() if err != nil { - return err + log.Printf("Skipping device %v", app) + } else { + uuidMap[strings.ReplaceAll(info.SsdpUdn, "-", "")] = *app } - uuidMap[strings.ReplaceAll(info.SsdpUdn, "-", "")] = *app } h.mu.Lock()