Skip to content

Commit

Permalink
Revert "Allow tracing the connection to debug connectivity problems. …
Browse files Browse the repository at this point in the history
…This is done to avoid extensive logs during standard debug. Please note, you need to enable both, 'trace_connection=true' as well as debug mode to see the messages." to not clutter this PR. Will add another PR instead.

This reverts commit 3d235f1.
  • Loading branch information
Sven Rebhan committed May 18, 2021
1 parent 253ddcc commit efabb1a
Showing 1 changed file with 0 additions and 17 deletions.
17 changes: 0 additions & 17 deletions plugins/inputs/modbus/modbus.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ type Modbus struct {
Timeout config.Duration `toml:"timeout"`
Retries int `toml:"busy_retries"`
RetriesWaitTime config.Duration `toml:"busy_retries_wait"`
TraceConnection bool `toml:"trace_connection"`
Log telegraf.Logger `toml:"-"`
// Register configuration
ConfigurationOriginal
Expand Down Expand Up @@ -98,8 +97,6 @@ const sampleConfig = `
# stop_bits = 1
# transmission_mode = "RTU"
## Trace the connection to the modbus device as debug messages
# trace_connection = false
## Measurements
##
Expand Down Expand Up @@ -251,9 +248,6 @@ func (m *Modbus) initClient() error {
}
handler := mb.NewTCPClientHandler(host + ":" + port)
handler.Timeout = time.Duration(m.Timeout)
if m.TraceConnection {
handler.Logger = m
}
m.handler = handler
case "file":
switch m.TransmissionMode {
Expand All @@ -264,9 +258,6 @@ func (m *Modbus) initClient() error {
handler.DataBits = m.DataBits
handler.Parity = m.Parity
handler.StopBits = m.StopBits
if m.TraceConnection {
handler.Logger = m
}
m.handler = handler
case "ASCII":
handler := mb.NewASCIIClientHandler(u.Path)
Expand All @@ -275,9 +266,6 @@ func (m *Modbus) initClient() error {
handler.DataBits = m.DataBits
handler.Parity = m.Parity
handler.StopBits = m.StopBits
if m.TraceConnection {
handler.Logger = m
}
m.handler = handler
default:
return fmt.Errorf("invalid protocol '%s' - '%s' ", u.Scheme, m.TransmissionMode)
Expand Down Expand Up @@ -436,11 +424,6 @@ func (m *Modbus) collectFields(acc telegraf.Accumulator, timestamp time.Time, ta
}
}

// Implement the logger interface of the modbus client
func (m *Modbus) Printf(format string, v ...interface{}) {
m.Log.Debugf(format, v...)
}

// Add this plugin to telegraf
func init() {
inputs.Add("modbus", func() telegraf.Input { return &Modbus{} })
Expand Down

0 comments on commit efabb1a

Please sign in to comment.