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

Cleanup logging 1 #1359

Merged
merged 7 commits into from
Jun 18, 2015
Merged

Cleanup logging 1 #1359

merged 7 commits into from
Jun 18, 2015

Conversation

rht
Copy link
Contributor

@rht rht commented Jun 12, 2015

Remove prefixlog (totally unused) and go-logging (backend of util/log).
Now there are only util/log, eventlog, logrus left (util/log and eventlog use logrus as backend).
Side-effect: the logs don't have shortfile (because logrus doesn't use it), and the formatting is less flexible than go-logging. The former needs a fork, the latter only needs a custom formatter.
#593

@jbenet jbenet added the backlog label Jun 12, 2015
@@ -3,23 +3,21 @@ package util
import (
"os"

logging "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/whyrusleeping/go-logging"
"github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/Sirupsen/logrus"
Copy link
Member

Choose a reason for hiding this comment

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

@whyrusleeping had you switched to go-logging on purpose?

Copy link
Member

Choose a reason for hiding this comment

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

i was under the assumption that we were using go-logging.

Copy link
Member

Choose a reason for hiding this comment

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

@whyrusleeping do you want to keep go-logging, or is logrus ok? (i dont care either way)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jbenet irc logs and past issues say logrus is the preferred backend. Some of the logs are even in pure logrus. It's just that eventlog heavy logging needs to be toned down somehow.

The argument for go-logging is that it is more lightweight than logrus and more compatible with standard logging extra features (e.g. logrus's setflags feature is still pending).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

keep go-logging is euphemism for kill logrus (as this will be the course of action written in the commit message, not the former)

Copy link
Member

Choose a reason for hiding this comment

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

@rht at this point, you know more about them to make a better decision on the two. I'd say take the path of least resistance if theyre about the same.

@rht
Copy link
Contributor Author

rht commented Jun 14, 2015

"completely API compatible with the standard library logger" but doesn't have stdlib SetFlags is indeed surprising. sirupsen/logrus#63

@rht rht force-pushed the cleanup-logging branch 10 times, most recently from 8af084f to bc0183f Compare June 16, 2015 17:29
@whyrusleeping
Copy link
Member

@rht, status update here?

@jbenet
Copy link
Member

jbenet commented Jun 16, 2015

@whyrusleeping said:

@rht at this point, you know more about them to make a better decision on the two. I'd say take the path of least resistance if theyre about the same.

so let's go with whatever you think is best, @rht. is that logrus + the changes here?

@rht
Copy link
Contributor Author

rht commented Jun 17, 2015

@whyrusleeping There is a very specific error that happens here when I switch Critical{,f} with Fatalf{,f}. I'm bisecting on my previous commit (now that gpe is not running). The err is erring.

Yes it is logrus + changes.

@jbenet
Copy link
Member

jbenet commented Jun 17, 2015

@rht is the problem these:

17:36:47.598 CRITI   boguskey: TestBogusPrivateKey.Sign -- this better be a test! key.go:54
FAIL    github.com/ipfs/go-ipfs/test/integration    11.337s

??

it's because in logrus, log.Fatalf calls os.Exit(1) after logging:

// Calls os.Exit(1) after logging
log.Fatal("Bye.")
// Calls panic() after logging
log.Panic("I'm bailing.")

https://github.com/Sirupsen/logrus#level-logging

Our Critical does not cause that sort of failure, so we can probably just change all occurrences of log.Critical{,f} to log.Error{,f}

@rht
Copy link
Contributor Author

rht commented Jun 17, 2015

(I c, I did try changing to error, but not to all files...). So Fatal will be used when in the lines there are explicit exits.

@rht rht force-pushed the cleanup-logging branch 8 times, most recently from f9e4205 to 20b87d1 Compare June 17, 2015 14:23
@rht
Copy link
Contributor Author

rht commented Jun 17, 2015

Test passes on the commit "Replace Critical with Error". The latest fail is only on the linux.

@rht
Copy link
Contributor Author

rht commented Jun 17, 2015

Will close #592, #1217. Cleanup logging 2 will be for #593.

@@ -96,7 +96,7 @@ func (pm *WantManager) SendBlock(ctx context.Context, env *engine.Envelope) {
log.Infof("Sending block %s to %s", env.Peer, env.Block)
err := pm.network.SendMessage(ctx, env.Peer, msg)
if err != nil {
log.Noticef("sendblock error: %s", err)
log.Warningf("sendblock error: %s", 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 should probably just be log.Infof -- warnings are things the user may need to be conscious about

@jbenet
Copy link
Member

jbenet commented Jun 18, 2015

last couple changes. otherwise, this LGTM!

@jbenet
Copy link
Member

jbenet commented Jun 18, 2015

@rht, make sure to rebase on latest master. we might merge @whyrusleeping's #1382 if it gets finished first.

rht added 7 commits June 18, 2015 10:03
License: MIT
Signed-off-by: rht <rhtbot@gmail.com>
Except when there is an explicit os.Exit(1) after the Critical line,
then replace with Fatal{,f}.
golang's log and logrus already call os.Exit(1) by default with Fatal.

License: MIT
Signed-off-by: rht <rhtbot@gmail.com>
And substitute the lines using Notice{,f} with Info{,f}

License: MIT
Signed-off-by: rht <rhtbot@gmail.com>
License: MIT
Signed-off-by: rht <rhtbot@gmail.com>
License: MIT
Signed-off-by: rht <rhtbot@gmail.com>
License: MIT
Signed-off-by: rht <rhtbot@gmail.com>
and exchange/bitswap/testutils.go

License: MIT
Signed-off-by: rht <rhtbot@gmail.com>
@rht
Copy link
Contributor Author

rht commented Jun 18, 2015

Fixed + rebased

@jbenet
Copy link
Member

jbenet commented Jun 18, 2015

@rht this LGTM! and 👍 on all the go linting.

jbenet added a commit that referenced this pull request Jun 18, 2015
@jbenet jbenet merged commit 152247d into ipfs:master Jun 18, 2015
@jbenet jbenet removed the backlog label Jun 18, 2015
@jbenet
Copy link
Member

jbenet commented Jun 18, 2015

thanks @rht!

@jbenet jbenet mentioned this pull request Jun 18, 2015
55 tasks
@rht
Copy link
Contributor Author

rht commented Jun 18, 2015

The golint was an excuse to rerun the travis.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants