flesh out logging
Some checks reported errors
Gitea/etcdmtr/pipeline/head Something is wrong with the build of this commit

This commit is contained in:
dave 2024-02-25 22:14:00 -08:00
parent c49fea2c40
commit 2e1892a063
2 changed files with 10 additions and 3 deletions

View File

@ -4,6 +4,7 @@ import (
"crypto/tls"
"crypto/x509"
"fmt"
"git.davepedu.com/dave/etcdmtr/pkg/etcdmtr"
"github.com/jessevdk/go-flags"
clientv3 "go.etcd.io/etcd/client/v3"
"go.uber.org/zap"
@ -92,6 +93,10 @@ func (c *Client) GetEtcdWithEndpoints(endpoints []string) (*clientv3.Client, err
})
}
func getLogger() *etcdmtr.ELog {
return etcdmtr.NewRootLogger()
}
func main() {
args := &EtcdMtrArgs{}
positionals, err := flags.Parse(args)
@ -105,13 +110,15 @@ func main() {
os.Exit(2)
}
logger := getLogger()
if args.Version {
fmt.Println("0.0.1")
os.Exit(0)
}
if len(positionals) < 1 {
log.Fatal("must specify endpoints")
logger.Fatal("must specify endpoints")
}
if !args.Insecure {
@ -126,7 +133,7 @@ func main() {
client, err := NewClient(positionals, args.ClientCert, args.ClientKey, args.ServerCA, args.Debug)
if err != nil {
panic(err)
logger.Fatal("couldn't get client: %s", err.Error())
}
etcd, err := client.GetEtcd()

2
go.mod
View File

@ -5,6 +5,7 @@ go 1.22.0
require (
github.com/jessevdk/go-flags v1.5.0
go.etcd.io/etcd/client/v3 v3.5.12
go.uber.org/zap v1.17.0
golang.org/x/net v0.21.0
)
@ -17,7 +18,6 @@ require (
go.etcd.io/etcd/client/pkg/v3 v3.5.12 // indirect
go.uber.org/atomic v1.7.0 // indirect
go.uber.org/multierr v1.6.0 // indirect
go.uber.org/zap v1.17.0 // indirect
golang.org/x/sys v0.17.0 // indirect
golang.org/x/text v0.14.0 // indirect
google.golang.org/genproto v0.0.0-20230822172742-b8732ec3820d // indirect