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

Make logging configurable #605

Merged
merged 12 commits into from
Oct 20, 2018

Conversation

srfrog
Copy link
Contributor

@srfrog srfrog commented Oct 4, 2018

This PR makes default logging silent and toggeable.

Closes #556


This change is Reviewable

This PR adds two new build tags for enabling and disabling
info and event logging. By default, no logging is enabled.

Closes #556
@srfrog srfrog changed the title New build tags to control logging. Make logging configurable Oct 11, 2018
Copy link
Contributor

@manishrjain manishrjain left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 9 files reviewed, 3 unresolved discussions (waiting on @srfrog and @manishrjain)


debug/debug.go, line 18 at r1 (raw file):

package debug

Can move logger.go into this file. There's not much going on here, so better to consolidate all logic here.


debug/events.go, line 45 at r1 (raw file):

func NewEventLog(family, title string) EventLogger {
	if eventLogger != nil {
		return eventLogger

Can't return the same event logger. Each event logger tracks different events types.

I think you don't need to bring event logging into this fold, because it doesn't pollute the logs that a user typically sees. And even in /debug/events, it is a separate "Badger" family, which is clearly separate and labeled. Never heard anyone complain about this. So, let's remove event logging from this abstraction.


debug/logger.go, line 21 at r1 (raw file):

// Logger is implemented by any logging system that is used for standard logs.
type Logger interface {
	Printf(string, ...interface{})

Have Infof, Warninf, and Errorf as the methods in the interface, and then you can provide a standard logger, which uses Printf internally to support all those, for convenience.

See: https://github.com/etcd-io/etcd/blob/master/raft/logger.go for reference.

srfrog added 2 commits October 17, 2018 12:57
updated Logger interface for error, info and warnings.
renamed debug package to "log".
added a default logger using Go log.
setting default logger at init.
Copy link
Contributor Author

@srfrog srfrog left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 5 files reviewed, 3 unresolved discussions (waiting on @manishrjain)


debug/debug.go, line 18 at r1 (raw file):

Previously, manishrjain (Manish R Jain) wrote…

Can move logger.go into this file. There's not much going on here, so better to consolidate all logic here.

Done.


debug/events.go, line 45 at r1 (raw file):

Previously, manishrjain (Manish R Jain) wrote…

Can't return the same event logger. Each event logger tracks different events types.

I think you don't need to bring event logging into this fold, because it doesn't pollute the logs that a user typically sees. And even in /debug/events, it is a separate "Badger" family, which is clearly separate and labeled. Never heard anyone complain about this. So, let's remove event logging from this abstraction.

Done.


debug/logger.go, line 21 at r1 (raw file):

Previously, manishrjain (Manish R Jain) wrote…

Have Infof, Warninf, and Errorf as the methods in the interface, and then you can provide a standard logger, which uses Printf internally to support all those, for convenience.

See: https://github.com/etcd-io/etcd/blob/master/raft/logger.go for reference.

Done.

Copy link
Contributor

@manishrjain manishrjain left a comment

Choose a reason for hiding this comment

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

:lgtm: I like how simple this is now. One small comment, and then this is ready to go.

Reviewed 1 of 9 files at r1, 7 of 9 files at r2.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @srfrog)


db.go, line 903 at r2 (raw file):

			}
			// Encounterd error. Retry indefinitely.
			Errorf("failure while flushing memtable to disk: %v. Retrying...\n", err)

Capital f in failure.

Copy link
Contributor Author

@srfrog srfrog left a comment

Choose a reason for hiding this comment

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

Reviewable status: 4 of 5 files reviewed, 1 unresolved discussion (waiting on @manishrjain)


db.go, line 903 at r2 (raw file):

Previously, manishrjain (Manish R Jain) wrote…

Capital f in failure.

Done.

@srfrog srfrog merged commit fbb2778 into master Oct 20, 2018
@srfrog srfrog deleted the feature/issue-556_make_badger_logging_configurable branch October 20, 2018 04:27
@JeanMertz
Copy link

Just a quick note:

  • I doesn't look this change is part of an official release yet
  • The introduction of the extra log lines (as reported in Make Badger logging configurable #556) is part of the latest release 1.5.4
  • But that release isn't in the CHANGELOG or on the Releases page (there's a Git tag for it though)
  • We noticed it because updating to the latest version introduced a lot of Badger specific log lines in our benchmarks. Thanks for fixing that, hope this will finds its way to a new release soon 👍

@leonklingele
Copy link

How does this PR make "default logging silent"?

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

Successfully merging this pull request may close these issues.

Make Badger logging configurable
4 participants