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

refactor(cmd/influxd): parse log-level CLI opts directly to correct type #20196

Merged
merged 3 commits into from
Nov 30, 2020

Conversation

danxmoran
Copy link
Contributor

Part of #19976

This took more boilerplate than I expected, I could be convinced it's not worth the trouble.

"go.uber.org/zap/zapcore"
)

type levelValue zapcore.Level
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This boilerplate file is pretty much identical to kit/cli/idflag.go, but with zapcore.Level instead of influxdb.ID.

}
if s := v.GetString(envVar); s != "" {
_ = (*destP).Set(v.GetString(envVar))
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This block is mostly boilerplate, following the same pattern as the preceding cases

"go.uber.org/zap/zapcore"
)

type levelValue zapcore.Level
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this definition just a way to declare methods on the zapcore.Level type? Nice trick!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

(I think) yes, specifically so we can redefine methods like String and Set that already exist on the zapcore.Level type.

@danxmoran danxmoran merged commit 4235c12 into master Nov 30, 2020
@danxmoran danxmoran deleted the dm-log-level-cli-opt branch November 30, 2020 18:59
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.

None yet

2 participants