Make artmap debug logging conditional on DebugArtmap flag
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
17
artmap.go
17
artmap.go
@@ -52,21 +52,21 @@ func (t *Tendrils) probeArtmap(ip net.IP) {
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
server := resp.Header.Get("Server")
|
||||
if server != "artmap" {
|
||||
if server != "" {
|
||||
log.Printf("[artmap] unexpected server header ip=%s server=%q", ip, server)
|
||||
}
|
||||
if resp.Header.Get("Server") != "artmap" {
|
||||
return
|
||||
}
|
||||
|
||||
var cfg artmapConfig
|
||||
if err := json.NewDecoder(resp.Body).Decode(&cfg); err != nil {
|
||||
if t.DebugArtmap {
|
||||
log.Printf("[artmap] decode error ip=%s: %v", ip, err)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
if t.DebugArtmap {
|
||||
log.Printf("[artmap] found ip=%s targets=%d mappings=%d", ip, len(cfg.Targets), len(cfg.Mappings))
|
||||
}
|
||||
|
||||
t.processArtmapConfig(&cfg)
|
||||
}
|
||||
@@ -76,13 +76,11 @@ func (t *Tendrils) processArtmapConfig(cfg *artmapConfig) {
|
||||
for _, target := range cfg.Targets {
|
||||
ip := parseTargetIP(target.Address)
|
||||
if ip == nil {
|
||||
log.Printf("[artmap] failed to parse target address %q", target.Address)
|
||||
continue
|
||||
}
|
||||
|
||||
node := t.nodes.GetByIP(ip)
|
||||
if node == nil {
|
||||
log.Printf("[artmap] target ip=%s not found as node", ip)
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -90,12 +88,15 @@ func (t *Tendrils) processArtmapConfig(cfg *artmapConfig) {
|
||||
switch target.Universe.Protocol {
|
||||
case "artnet":
|
||||
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)
|
||||
}
|
||||
case "sacn":
|
||||
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)
|
||||
}
|
||||
default:
|
||||
log.Printf("[artmap] unknown protocol %q for target %s", target.Universe.Protocol, target.Address)
|
||||
continue
|
||||
}
|
||||
updated = true
|
||||
|
||||
Reference in New Issue
Block a user