Skip to content

Commit

Permalink
Make use of logger interface inside of the Consul BE
Browse files Browse the repository at this point in the history
  • Loading branch information
sean- committed Apr 26, 2016
1 parent 455b768 commit eaa60ee
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions physical/consul.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,11 @@ func newConsulBackend(conf map[string]string, logger *log.Logger) (Backend, erro

// Ensure path is suffixed but not prefixed
if !strings.HasSuffix(path, "/") {
logger.Printf("[WARN]: consul: appending trailing forward slash to path")
path += "/"
}
if strings.HasPrefix(path, "/") {
logger.Printf("[WARN]: consul: trimming path of its forward slash")
path = strings.TrimPrefix(path, "/")
}

Expand Down Expand Up @@ -158,6 +160,7 @@ func newConsulBackend(conf map[string]string, logger *log.Logger) (Backend, erro
if err != nil {
return nil, errwrap.Wrapf("failed parsing max_parallel parameter: {{err}}", err)
}
logger.Printf("[DEBUG]: consul: max_parallel set to %d", maxParInt)
}

// Setup the backend
Expand Down Expand Up @@ -213,7 +216,7 @@ func (c *ConsulBackend) AdvertiseActive(active bool) error {
return nil
}

// wtb logger c.logger.Printf("[WARN] service registration failed: %v", err)
c.logger.Printf("[WARN] consul: service registration failed: %v", err)
c.serviceLock.Unlock()
time.Sleep(registrationRetryInterval)
c.serviceLock.Lock()
Expand Down Expand Up @@ -304,13 +307,13 @@ func (c *ConsulBackend) RunServiceDiscovery(shutdownCh ShutdownChannel, advertis
for {
select {
case <-shutdownCh:
// wtb logger: log.Printf("[DEBUG]: Shutting down consul backend")
c.logger.Printf("[INFO]: consul: Shutting down consul backend")
break shutdown
}
}

if err := agent.ServiceDeregister(serviceID); err != nil {
// wtb logger: log.Printf("[WARNING]: service deregistration failed: {{err}}", err)
c.logger.Printf("[WARN]: consul: service deregistration failed: {{err}}", err)
}
c.running = false
}()
Expand Down

0 comments on commit eaa60ee

Please sign in to comment.