diff --git a/agent/agent.go b/agent/agent.go index eac75560b..76cc03de6 100644 --- a/agent/agent.go +++ b/agent/agent.go @@ -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" { diff --git a/api/watch/plan.go b/api/watch/plan.go index 6cf11157c..f3b7981fb 100644 --- a/api/watch/plan.go +++ b/api/watch/plan.go @@ -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 diff --git a/api/watch/watch.go b/api/watch/watch.go index 09ee15edd..1dce25291 100644 --- a/api/watch/watch.go +++ b/api/watch/watch.go @@ -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