Make artmap debug logging conditional on DebugArtmap flag

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Ian Gulliver
2026-01-30 15:45:11 -08:00
parent 1618ef1b87
commit 1b2646a496

View File

@@ -52,21 +52,21 @@ func (t *Tendrils) probeArtmap(ip net.IP) {
} }
defer resp.Body.Close() defer resp.Body.Close()
server := resp.Header.Get("Server") if resp.Header.Get("Server") != "artmap" {
if server != "artmap" {
if server != "" {
log.Printf("[artmap] unexpected server header ip=%s server=%q", ip, server)
}
return return
} }
var cfg artmapConfig var cfg artmapConfig
if err := json.NewDecoder(resp.Body).Decode(&cfg); err != nil { if err := json.NewDecoder(resp.Body).Decode(&cfg); err != nil {
if t.DebugArtmap {
log.Printf("[artmap] decode error ip=%s: %v", ip, err) log.Printf("[artmap] decode error ip=%s: %v", ip, err)
}
return return
} }
if t.DebugArtmap {
log.Printf("[artmap] found ip=%s targets=%d mappings=%d", ip, len(cfg.Targets), len(cfg.Mappings)) log.Printf("[artmap] found ip=%s targets=%d mappings=%d", ip, len(cfg.Targets), len(cfg.Mappings))
}
t.processArtmapConfig(&cfg) t.processArtmapConfig(&cfg)
} }
@@ -76,13 +76,11 @@ func (t *Tendrils) processArtmapConfig(cfg *artmapConfig) {
for _, target := range cfg.Targets { for _, target := range cfg.Targets {
ip := parseTargetIP(target.Address) ip := parseTargetIP(target.Address)
if ip == nil { if ip == nil {
log.Printf("[artmap] failed to parse target address %q", target.Address)
continue continue
} }
node := t.nodes.GetByIP(ip) node := t.nodes.GetByIP(ip)
if node == nil { if node == nil {
log.Printf("[artmap] target ip=%s not found as node", ip)
continue continue
} }
@@ -90,12 +88,15 @@ func (t *Tendrils) processArtmapConfig(cfg *artmapConfig) {
switch target.Universe.Protocol { switch target.Universe.Protocol {
case "artnet": case "artnet":
t.nodes.UpdateArtNet(node, []int{universe}, nil) t.nodes.UpdateArtNet(node, []int{universe}, nil)
if t.DebugArtmap {
log.Printf("[artmap] marked %s (%s) as artnet input for universe %d", node.DisplayName(), ip, universe) log.Printf("[artmap] marked %s (%s) as artnet input for universe %d", node.DisplayName(), ip, universe)
}
case "sacn": case "sacn":
t.nodes.UpdateSACNUnicastInputs(node, []int{universe}) t.nodes.UpdateSACNUnicastInputs(node, []int{universe})
if t.DebugArtmap {
log.Printf("[artmap] marked %s (%s) as sacn input for universe %d", node.DisplayName(), ip, universe) log.Printf("[artmap] marked %s (%s) as sacn input for universe %d", node.DisplayName(), ip, universe)
}
default: default:
log.Printf("[artmap] unknown protocol %q for target %s", target.Universe.Protocol, target.Address)
continue continue
} }
updated = true updated = true