Skip to content
This repository has been archived by the owner on Oct 18, 2018. It is now read-only.

Use logger in config service client as default logger for kv client #187

Merged
merged 4 commits into from Oct 25, 2017

Conversation

cw9
Copy link
Contributor

@cw9 cw9 commented Oct 21, 2017

Seems current logic means the kv client in m3db will be using nulllogger as well, we probably need to upgrade all repos with this change, seems the only place with a real logger with the previous version is the one in m3aggregator where we explicitly set a logger with Warn level.

@robskillington @xichen2020 @prateek @jeromefroe

@coveralls
Copy link

coveralls commented Oct 21, 2017

Coverage Status

Coverage decreased (-0.06%) to 83.202% when pulling 5af0ff7 on chao-kv-config into 2548d2d on master.

@@ -311,7 +309,7 @@ func validateTopLevelNamespace(namespace string) error {
}

func (c *csclient) sanitizeOptions(opts kv.Options) (kv.Options, error) {
if opts.Logger() == nil {
if opts.Logger() == nil || reflect.DeepEqual(opts.Logger(), log.NullLogger) {
Copy link
Contributor

Choose a reason for hiding this comment

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

We can probably just do opts.Logger() == log.NullLogger here?

Copy link
Contributor Author

@cw9 cw9 Oct 21, 2017

Choose a reason for hiding this comment

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

We can't, the NullLogger is not comparable, I guess because of the slice of fields in it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sure, but log.NullLogger is a singleton and of type Logger, which is an interface, we should be able to compare interface pointers no?

Copy link
Contributor Author

@cw9 cw9 Oct 21, 2017

Choose a reason for hiding this comment

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

Are you saying we should compare the address of the struct under the log.Logger interface? but I don't see how can we we get that without using reflect or unsafe pointer? Please feel free to commandeer this pr if there is an easy way to do it.

Or we can define NullLogger as var NullLogger Logger = &nullLogger{} to cheat around it.

Copy link
Contributor

Choose a reason for hiding this comment

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

What I meant was NullLogger is a singleton and of Logger type, which is an interface. Therefore under the hood, NullLogger contains a pointer to the slice fields in the null logger on the heap. As such, checking opts.Logger() == log.NullLogger should just work. FWIW I just tried it and it builds locally.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah I see, didn't realize the NullLogger wasn't a pointer type by itself, which would cause a panic during runtime. Put up a m3x PR here to make NullLogger a pointer type: m3db/m3x#108 and updated this PR to use direct logger comparison without reflection.

@coveralls
Copy link

coveralls commented Oct 22, 2017

Coverage Status

Coverage increased (+0.06%) to 83.323% when pulling 6cfb7c9 on chao-kv-config into 2548d2d on master.

SetNamespace(kvPrefix).
SetEnvironment(c.opts.Env())
c.txn, c.txnErr = c.createTxnStore(kvOpts)
c.txn, c.txnErr = c.TxnStore(kv.NewOptions())
Copy link
Contributor

Choose a reason for hiding this comment

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

We don't need to set the namespace and environment here anymore?

Copy link
Contributor

Choose a reason for hiding this comment

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

That's taken care of in sanitizeOptions.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, I see, Github had collapsed those lines in my view lol.

Copy link
Contributor

@jeromefroe jeromefroe left a comment

Choose a reason for hiding this comment

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

LGTM

SetNamespace(kvPrefix).
SetEnvironment(c.opts.Env())
c.txn, c.txnErr = c.createTxnStore(kvOpts)
c.txn, c.txnErr = c.TxnStore(kv.NewOptions())
Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, I see, Github had collapsed those lines in my view lol.

@coveralls
Copy link

coveralls commented Oct 25, 2017

Coverage Status

Coverage increased (+0.03%) to 83.293% when pulling 2639d90 on chao-kv-config into 2548d2d on master.

@cw9 cw9 merged commit c4d51f0 into master Oct 25, 2017
@cw9 cw9 deleted the chao-kv-config branch October 25, 2017 19:46
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants