use micro logger instead of hclog.Logger

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
2020-12-09 13:15:36 +03:00
parent e4dca0ce20
commit 883757b7f8
4 changed files with 141 additions and 4 deletions

View File

@@ -5,7 +5,7 @@ import (
"encoding/json"
"errors"
api "github.com/hashicorp/consul/api"
"github.com/hashicorp/consul/api"
"github.com/unistack-org/micro/v3/config"
)
@@ -30,12 +30,22 @@ func (c *consulConfig) Init(opts ...config.Option) error {
o(&c.opts)
}
cfg := api.DefaultConfig()
cfg := api.DefaultConfigWithLogger(&consulLogger{logger: c.opts.Logger})
path := ""
if c.opts.Context != nil {
if v, ok := c.opts.Context.Value(configKey{}).(*api.Config); ok {
cfg = v
cfg.Address = v.Address
cfg.Scheme = v.Scheme
cfg.Datacenter = v.Datacenter
cfg.Transport = v.Transport
cfg.HttpClient = v.HttpClient
cfg.HttpAuth = v.HttpAuth
cfg.WaitTime = v.WaitTime
cfg.Token = v.Token
cfg.TokenFile = v.TokenFile
cfg.Namespace = v.Namespace
cfg.TLSConfig = v.TLSConfig
}
if v, ok := c.opts.Context.Value(addrKey{}).(string); ok {
@@ -49,7 +59,6 @@ func (c *consulConfig) Init(opts ...config.Option) error {
if v, ok := c.opts.Context.Value(pathKey{}).(string); ok {
path = v
}
}
cli, err := api.NewClient(cfg)