Repository: syncthing/syncthing (language: go)

Issue:
Lower the log level of "already connected to this device" to DEBUG (is: INFO)
### Feature description

Lower the logging level for `XXX already connected to this device` messages in the log from `INFO` to `DEBUG`.

### Problem or use case

There are many lines in the logs coming from an expected race condition when two devices connect. See for instance https://forum.syncthing.net/t/connected-to-already-connected-device/13190 for an example of a related question.

Since they are expected and do not indicate an error they are not useful to see in a normal, production log. The sheer number of these messages makes it difficult to find actually useful ones.

### Alternatives or workarounds

Filter out the messages if the logging interface allows it - this will not help with `syncthing*.log` ones for instance on Windows.


Discussion / hints:
@wsw70 I would like to work on this issue. Could you please assign it to me ?
Issues are not assigned here. If you've got a solution to the problem, just file a PR 🙂.

Fix patch:
diff --git a/lib/connections/service.go b/lib/connections/service.go
index 5b69f2f99a6..0a09f6c7ced 100644
--- a/lib/connections/service.go
+++ b/lib/connections/service.go
@@ -283,7 +283,11 @@ func (s *service) handleConns(ctx context.Context) error {
 		}
 
 		if err := s.connectionCheckEarly(remoteID, c); err != nil {
-			l.Infof("Connection from %s at %s (%s) rejected: %v", remoteID, c.RemoteAddr(), c.Type(), err)
+			if errors.Is(err, errDeviceAlreadyConnected) {
+				l.Debugf("Connection from %s at %s (%s) rejected: %v", remoteID, c.RemoteAddr(), c.Type(), err)
+			} else {
+				l.Infof("Connection from %s at %s (%s) rejected: %v", remoteID, c.RemoteAddr(), c.Type(), err)
+			}
 			c.Close()
 			continue
 		}


Test patch: