Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lib/connections: Consistent log levels & polish (fixes #4510) #4511

Closed
wants to merge 4 commits into from

Conversation

imsodin
Copy link
Member

@imsodin imsodin commented Nov 14, 2017

As Audrius mentioned in the linked issue, these functions would probably benefit from a general overhaul. Until that happens, this makes logging more consistent and less confusion to the user (info). It still logs to info level when the service fails at setup. During operation there was a mix of info and debug level logging, which now all happens on debug.

continue
}

err = dialer.SetTCPOptions(conn)
if err != nil {
l.Infoln(err)
l.Debugln(err)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need context

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I considered debug logging without context as ok, as the context can be established from file names and line numbers. I will add some (generic) context anyway.

@@ -104,7 +104,7 @@ func (t *tcpListener) Serve() {

err = dialer.SetTCPOptions(conn)
if err != nil {
l.Infoln(err)
l.Debugln(err)
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Context

@@ -39,7 +39,7 @@ func (d *tcpDialer) Dial(id protocol.DeviceID, uri *url.URL) (internalConn, erro

err = dialer.SetTCPOptions(conn)
if err != nil {
l.Infoln(err)
l.Debugln(err)
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Context

lib/upnp/upnp.go Outdated
@@ -159,7 +159,7 @@ USER-AGENT: syncthing/1.0

err = socket.SetDeadline(time.Now().Add(timeout))
if err != nil {
l.Infoln(err)
l.Debugln(err)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Context

lib/upnp/upnp.go Outdated
@@ -168,7 +168,7 @@ USER-AGENT: syncthing/1.0
_, err = socket.WriteTo(search, ssdp)
if err != nil {
if e, ok := err.(net.Error); !ok || !e.Timeout() {
l.Infoln(err)
l.Debugln(err)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Context

lib/upnp/upnp.go Outdated
@@ -168,7 +168,7 @@ USER-AGENT: syncthing/1.0
_, err = socket.WriteTo(search, ssdp)
if err != nil {
if e, ok := err.(net.Error); !ok || !e.Timeout() {
l.Infoln(err)
l.Debugln(err)
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should also tweak SetTCPOptions to not fail on first failure.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really know what you want here.

@@ -71,18 +74,18 @@ func (t *relayListener) Serve() {

conn, err := client.JoinSession(inv)
if err != nil {
l.Infoln("Joining relay session (BEP/relay):", err)
l.Debugln("Listen (BEP/relay): failed to join session:", err)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we really hide these? It's one of the only ways to debug the issues that are happening now.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was what I was asking originally. I was confused by what looked like randomly chosen info or debug levels with or without context (e.g. SetTCPOptions was info but without context, SetTrafficClass was debug but with context). I can't really judge their relevance, so pointers whether a log statement should be info or debug like this one are appreciated.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other errors that are returned by dial functions etc are logged a layer up, in the loop, so it's ok, yet this is the only place that reports relay issues, so it's not cool to hide it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The dial logging was only on debug, I changed that to info and removed some redundant debug log statements in the dial functions themselves.

@@ -95,7 +98,7 @@ func (t *relayListener) Serve() {
err = tlsTimedHandshake(tc)
if err != nil {
tc.Close()
l.Infoln("TLS handshake (BEP/relay):", err)
l.Debugln("Listen (BEP/relay): TLS handshake:", err)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, only place that reports listen errors, so not cool to hide it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will make everything log on info level that results in an early return/continue/break, does that sound sensible?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well I think I pointed out the relevant places in this change, but yeah, anything that doesn't return an error should probably be logged.

}

tc := tls.Server(conn, t.tlsCfg)
err = tlsTimedHandshake(tc)
if err != nil {
l.Infoln("TLS handshake (BEP/tcp):", err)
l.Debugln("TLS handshake (BEP/tcp):", err)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not cool to hide.

@@ -401,7 +401,7 @@ func (s *Service) connect() {

conn, err := dialer.Dial(deviceID, uri)
if err != nil {
l.Debugln("dial failed", deviceCfg.DeviceID, uri, err)
l.Infof("%v for %v at %v: %v", dialerFactory, deviceCfg.DeviceID, uri, err)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might flood, as we might have old addresses, so better this stays debug.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

@AudriusButkevicius
Copy link
Member

@st-review merge

@st-review
Copy link

👌 Merged as 4efff73. Thanks, @imsodin!

@st-review st-review closed this Nov 14, 2017
st-review pushed a commit that referenced this pull request Nov 14, 2017
@imsodin imsodin deleted the connDeb branch November 14, 2017 21:53
@st-review st-review added the pr-merged Legacy label used in the past for pull requests merged to the main tree label Jan 15, 2018
@st-review st-review added the frozen-due-to-age Issues closed and untouched for a long time, together with being locked for discussion label Nov 15, 2018
@syncthing syncthing locked and limited conversation to collaborators Nov 15, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
frozen-due-to-age Issues closed and untouched for a long time, together with being locked for discussion pr-merged Legacy label used in the past for pull requests merged to the main tree
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants