logging: create logger to prevent nil pointer

Create a new logger if one not found.
This commit is contained in:
Sahdev P. Zala 2020-05-31 19:25:47 -04:00
parent 9b6c3e3378
commit 659fb01a6c

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 {