Skip to content

Commit

Permalink
move bit extract logging behind the debug flag
Browse files Browse the repository at this point in the history
  • Loading branch information
Ted Scharff committed Oct 30, 2020
1 parent a950b1e commit 0d58e6a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ func createHandler(nodeConfig NodeConfig) MsgHandler {
var handler MsgHandler
if nodeConfig.ExtractBit != nil {
extractBit := int(nodeConfig.ExtractBit.(float64)) // JSON numbers are float64 by default
handler = OpcuaBitVectorHandler{g, extractBit}
handler = OpcuaBitVectorHandler{g, extractBit, *debug}
} else {
handler = OpcValueHandler{g}
}
Expand Down
5 changes: 4 additions & 1 deletion opcua_bitvector_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
type OpcuaBitVectorHandler struct {
gauge prometheus.Gauge
extractBit int // identifies the bit to extract. little endian bit & byte order.
debug bool
}

// Handle computes the float value and emit it as a prometheus metric.
Expand All @@ -27,7 +28,9 @@ func (h OpcuaBitVectorHandler) Handle(v ua.Variant) error {
if err != nil {
return err
}
log.Printf("Extracted bit number %d: value=%d", h.extractBit, int(floatVal))
if h.debug {
log.Printf("Extracted bit number %d: value=%d", h.extractBit, int(floatVal))
}
h.gauge.Set(floatVal)
return nil
}
Expand Down

0 comments on commit 0d58e6a

Please sign in to comment.