Make artmap debug logging conditional on DebugArtmap flag
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
25
artmap.go
25
artmap.go
@@ -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 {
|
||||||
log.Printf("[artmap] decode error ip=%s: %v", ip, err)
|
if t.DebugArtmap {
|
||||||
|
log.Printf("[artmap] decode error ip=%s: %v", ip, err)
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Printf("[artmap] found ip=%s targets=%d mappings=%d", ip, len(cfg.Targets), len(cfg.Mappings))
|
if t.DebugArtmap {
|
||||||
|
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)
|
||||||
log.Printf("[artmap] marked %s (%s) as artnet input for universe %d", node.DisplayName(), ip, universe)
|
if t.DebugArtmap {
|
||||||
|
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})
|
||||||
log.Printf("[artmap] marked %s (%s) as sacn input for universe %d", node.DisplayName(), ip, universe)
|
if t.DebugArtmap {
|
||||||
|
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
|
||||||
|
|||||||
Reference in New Issue
Block a user