summaryrefslogtreecommitdiff
path: root/service/container.go
diff options
context:
space:
mode:
Diffstat (limited to 'service/container.go')
-rw-r--r--service/container.go17
1 files changed, 9 insertions, 8 deletions
diff --git a/service/container.go b/service/container.go
index 3395cd86..0e89f224 100644
--- a/service/container.go
+++ b/service/container.go
@@ -5,6 +5,7 @@ import (
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
"sync"
+ "github.com/fatih/color"
)
// Config provides ability to slice configuration sections and unmarshal configuration data into
@@ -64,7 +65,7 @@ func (c *container) Register(name string, service Service) {
status: StatusRegistered,
})
- c.log.Debugf("%s.service: registered", name)
+ c.log.Debugf("%s: registered", color.GreenString(name))
}
// Check hasStatus svc has been registered.
@@ -102,18 +103,18 @@ func (c *container) Configure(cfg Config) error {
for _, e := range c.services {
if e.getStatus() >= StatusConfigured {
- return fmt.Errorf("service %s has already been configured", e.name)
+ return fmt.Errorf("service %s has already been configured", color.GreenString(e.name))
}
segment := cfg.Get(e.name)
if segment == nil {
- c.log.Debugf("%s.service: no config has been provided", e.name)
+ c.log.Debugf("%s: no config has been provided", color.GreenString(e.name))
continue
}
ok, err := e.svc.Configure(segment, c)
if err != nil {
- return errors.Wrap(err, fmt.Sprintf("%s.service", e.name))
+ return errors.Wrap(err, fmt.Sprintf("%s", color.GreenString(e.name)))
} else if ok {
e.setStatus(StatusConfigured)
}
@@ -138,14 +139,14 @@ func (c *container) Serve() error {
continue
}
- c.log.Debugf("%s.service: started", e.name)
+ c.log.Debugf("%s: started", color.GreenString(e.name))
go func(e *entry) {
e.setStatus(StatusServing)
defer e.setStatus(StatusStopped)
if err := e.svc.Serve(); err != nil {
- c.log.Errorf("%s.service: %s", e.name, err)
- done <- errors.Wrap(err, fmt.Sprintf("%s.service", e.name))
+ c.log.Errorf("%s: %s", color.GreenString(e.name), err)
+ done <- errors.Wrap(err, fmt.Sprintf("%s", color.GreenString(e.name)))
}
}(e)
}
@@ -173,7 +174,7 @@ func (c *container) Stop() {
if e.hasStatus(StatusServing) {
e.svc.Stop()
e.setStatus(StatusStopped)
- c.log.Debugf("%s.service: stopped", e.name)
+ c.log.Debugf("%s: stopped", color.GreenString(e.name))
}
}
}