Skip to content

Commit 6f3fc15

Browse files
committed
Reduced verbosity of logging
1 parent f236ff8 commit 6f3fc15

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

client.go

+9-9
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,13 @@ type Client struct {
4949
// ClientLogger is the interface that must be implemented by a logger
5050
// to be used in the discovery client.
5151
type ClientLogger interface {
52-
Infof(format string, args ...interface{})
52+
Debugf(format string, args ...interface{})
5353
Errorf(format string, args ...interface{})
5454
}
5555

5656
type nullClientLogger struct{}
5757

58-
func (l *nullClientLogger) Infof(format string, args ...interface{}) {}
58+
func (l *nullClientLogger) Debugf(format string, args ...interface{}) {}
5959
func (l *nullClientLogger) Errorf(format string, args ...interface{}) {}
6060

6161
type discoveryMessage struct {
@@ -132,7 +132,7 @@ func (disc *Client) jsonDecodeLoop(in io.Reader, outChan chan<- *discoveryMessag
132132
if err != nil {
133133
disc.logger.Errorf("Stopped decode loop: %v", err)
134134
} else {
135-
disc.logger.Infof("Stopped decode loop")
135+
disc.logger.Debugf("Stopped decode loop")
136136
}
137137
}
138138

@@ -146,7 +146,7 @@ func (disc *Client) jsonDecodeLoop(in io.Reader, outChan chan<- *discoveryMessag
146146
closeAndReportError(err)
147147
return
148148
}
149-
disc.logger.Infof("Received message %s", msg)
149+
disc.logger.Debugf("Received message %s", msg)
150150
if msg.EventType == "add" {
151151
if msg.Port == nil {
152152
closeAndReportError(errors.New("invalid 'add' message: missing port"))
@@ -193,7 +193,7 @@ func (disc *Client) waitMessage(timeout time.Duration) (*discoveryMessage, error
193193
}
194194

195195
func (disc *Client) sendCommand(command string) error {
196-
disc.logger.Infof("Sending command %s", strings.TrimSpace(command))
196+
disc.logger.Debugf("Sending command %s", strings.TrimSpace(command))
197197
data := []byte(command)
198198
for {
199199
n, err := disc.outgoingCommandsPipe.Write(data)
@@ -208,7 +208,7 @@ func (disc *Client) sendCommand(command string) error {
208208
}
209209

210210
func (disc *Client) runProcess() error {
211-
disc.logger.Infof("Starting discovery process")
211+
disc.logger.Debugf("Starting discovery process")
212212
proc, err := paths.NewProcess(nil, disc.processArgs...)
213213
if err != nil {
214214
return err
@@ -234,15 +234,15 @@ func (disc *Client) runProcess() error {
234234
disc.statusMutex.Lock()
235235
defer disc.statusMutex.Unlock()
236236
disc.process = proc
237-
disc.logger.Infof("Discovery process started")
237+
disc.logger.Debugf("Discovery process started")
238238
return nil
239239
}
240240

241241
func (disc *Client) killProcess() {
242242
disc.statusMutex.Lock()
243243
defer disc.statusMutex.Unlock()
244244

245-
disc.logger.Infof("Killing discovery process")
245+
disc.logger.Debugf("Killing discovery process")
246246
if process := disc.process; process != nil {
247247
disc.process = nil
248248
if err := process.Kill(); err != nil {
@@ -252,7 +252,7 @@ func (disc *Client) killProcess() {
252252
disc.logger.Errorf("Waiting discovery process termination: %v", err)
253253
}
254254
}
255-
disc.logger.Infof("Discovery process killed")
255+
disc.logger.Debugf("Discovery process killed")
256256
}
257257

258258
// Run starts the discovery executable process and sends the HELLO command to the discovery to agree on the

client_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import (
2929

3030
type testLogger struct{}
3131

32-
func (l *testLogger) Infof(msg string, args ...any) {
32+
func (l *testLogger) Debugf(msg string, args ...any) {
3333
fmt.Printf(msg, args...)
3434
fmt.Println()
3535
}

0 commit comments

Comments
 (0)