mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
logging: create logger to prevent nil pointer
Create a new logger if one not found.
This commit is contained in:
parent
9b6c3e3378
commit
659fb01a6c
@ -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 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user