Merge pull request #11962 from spzala/incorrectflag

logging: create logger to prevent nil pointer
This commit is contained in:
Sahdev Zala 2020-06-09 14:34:22 -04:00 committed by GitHub
commit 84a5ff2d97
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -57,6 +57,15 @@ func startEtcdOrProxyV2() {
err := cfg.parse(os.Args[1:])
lg := cfg.ec.GetLogger()
if lg == nil {
var zapError error
// use this logger
lg, zapError = zap.NewProduction()
if zapError != nil {
fmt.Printf("error creating zap logger %v", zapError)
os.Exit(1)
}
}
if err != nil {
lg.Warn("failed to verify flags", zap.Error(err))
switch err {