api: Use a Logger instead of an io.Writer in api.Watch
So that we can pass around only a Logger, not a LogOutput
This commit is contained in:
parent
c7c941811d
commit
7c4566f116
|
@ -1263,7 +1263,7 @@ func (a *Agent) reloadWatches(cfg *config.RuntimeConfig) error {
|
|||
httpConfig := wp.Exempt["http_handler_config"].(*watch.HttpHandlerConfig)
|
||||
wp.Handler = makeHTTPWatchHandler(a.logger, httpConfig)
|
||||
}
|
||||
wp.LogOutput = a.LogOutput
|
||||
wp.Logger = a.logger.Named("watch")
|
||||
|
||||
addr := config.Address
|
||||
if config.Scheme == "https" {
|
||||
|
|
|
@ -31,8 +31,10 @@ func (p *Plan) Run(address string) error {
|
|||
|
||||
// Run is used to run a watch plan
|
||||
func (p *Plan) RunWithConfig(address string, conf *consulapi.Config) error {
|
||||
// Create the logger
|
||||
logger := newWatchLogger(p.LogOutput)
|
||||
logger := p.Logger
|
||||
if logger == nil {
|
||||
logger = newWatchLogger(p.LogOutput)
|
||||
}
|
||||
|
||||
// Setup the client
|
||||
p.address = address
|
||||
|
|
|
@ -8,6 +8,7 @@ import (
|
|||
"time"
|
||||
|
||||
consulapi "github.com/hashicorp/consul/api"
|
||||
"github.com/hashicorp/go-hclog"
|
||||
"github.com/mitchellh/mapstructure"
|
||||
)
|
||||
|
||||
|
@ -29,7 +30,10 @@ type Plan struct {
|
|||
// on index param. To support hash based watches, set HybridHandler instead.
|
||||
Handler HandlerFunc
|
||||
HybridHandler HybridHandlerFunc
|
||||
LogOutput io.Writer
|
||||
|
||||
Logger hclog.Logger
|
||||
// Deprecated: use Logger
|
||||
LogOutput io.Writer
|
||||
|
||||
address string
|
||||
client *consulapi.Client
|
||||
|
|
Loading…
Reference in New Issue