-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Suppress logging before flag.Parse
from glog
#2970
Conversation
Replace `goflag.Parse()` call with `goflag.CommandLine.Parse([]string{})` This serves multiple purposes 1. We don't actually parse the os.Args (which Parse() method internally does). This ensures that the command line arguments are parsed only by RootCmd.Execute() call (which is the parent command) 2. We suppress the `Error: Logging before flag.Parse...` warning messages. https://github.com/golang/glog/blob/master/glog.go#L679 causes the warning message and we suppress this warning by calling the Parse method on the underlying flagset. Signed-off-by: Ibrahim Jarif <jarifibrahim@gmail.com>
Signed-off-by: Ibrahim Jarif <jarifibrahim@gmail.com>
Can someone please restart the CI (dgraph) build? The previous build failed due to timeout. |
There was a problem hiding this 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 1 files reviewed, 3 unresolved discussions (waiting on @codexnull, @golangcibot, and @jarifibrahim)
dgraph/cmd/root.go, line 60 at r2 (raw file):
initCmds() // Convinces goflags that we have called Parse() to avoid noisy logs.
rewrite the comment in the passive voice.
"Convinces goflags that Parse() has been called ..."
dgraph/cmd/root.go, line 62 at r2 (raw file):
// Convinces goflags that we have called Parse() to avoid noisy logs. // https://github.com/kubernetes/kubernetes/issues/17162#issuecomment-225596212 // We don't need to check the error here.
Check the error, even if it's pointless, to clear the lint warning.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good to merge, once Martin approves this. Thanks for the change, @jarifibrahim .
Reviewable status: 0 of 1 files reviewed, 3 unresolved discussions (waiting on @golangcibot and @jarifibrahim)
There was a problem hiding this 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 1 files reviewed, 3 unresolved discussions (waiting on @golangcibot and @jarifibrahim)
Replace `goflag.Parse()` call with `goflag.CommandLine.Parse([]string{})` This serves multiple purposes 1. We don't actually parse the os.Args (which Parse() method internally does). This ensures that the command line arguments are parsed only by RootCmd.Execute() call (which is the parent command) 2. We suppress the `Error: Logging before flag.Parse...` warning messages. https://github.com/golang/glog/blob/master/glog.go#L679 causes the warning message and we suppress this warning by calling the Parse method on the underlying flagset. Signed-off-by: Ibrahim Jarif <jarifibrahim@gmail.com>
Replace
goflag.Parse()
call withgoflag.CommandLine.Parse([]string{})
This serves multiple purposes
Error: Logging before flag.Parse...
warning messages. https://github.com/golang/glog/blob/master/glog.go#L679 causes the warning message and we suppress this warning by calling the Parse method on the underlying flagset.Signed-off-by: Ibrahim Jarif jarifibrahim@gmail.com
Before this PR
with this PR
Related to #2890
This change is