change logging for service startup

This commit is contained in:
Asim Aslam 2020-04-23 11:24:39 +01:00
parent 6fa27373ed
commit 7345ce9192
2 changed files with 26 additions and 26 deletions

View File

@ -672,8 +672,8 @@ func (g *grpcServer) Register() error {
g.RUnlock()
if !registered {
if logger.V(logger.DebugLevel, logger.DefaultLogger) {
logger.Debugf("Registry [%s] Registering node: %s", config.Registry.String(), node.Id)
if logger.V(logger.InfoLevel, logger.DefaultLogger) {
logger.Infof("Registry [%s] Registering node: %s", config.Registry.String(), node.Id)
}
}
@ -707,8 +707,8 @@ func (g *grpcServer) Register() error {
opts = append(opts, broker.DisableAutoAck())
}
if logger.V(logger.DebugLevel, logger.DefaultLogger) {
logger.Debugf("Subscribing to topic: %s", sb.Topic())
if logger.V(logger.InfoLevel, logger.DefaultLogger) {
logger.Infof("Subscribing to topic: %s", sb.Topic())
}
sub, err := config.Broker.Subscribe(sb.Topic(), handler, opts...)
if err != nil {
@ -768,8 +768,8 @@ func (g *grpcServer) Deregister() error {
Nodes: []*registry.Node{node},
}
if logger.V(logger.DebugLevel, logger.DefaultLogger) {
logger.Debugf("Deregistering node: %s", node.Id)
if logger.V(logger.InfoLevel, logger.DefaultLogger) {
logger.Infof("Deregistering node: %s", node.Id)
}
if err := config.Registry.Deregister(service); err != nil {
return err
@ -787,8 +787,8 @@ func (g *grpcServer) Deregister() error {
for sb, subs := range g.subscribers {
for _, sub := range subs {
if logger.V(logger.DebugLevel, logger.DefaultLogger) {
logger.Debugf("Unsubscribing from topic: %s", sub.Topic())
if logger.V(logger.InfoLevel, logger.DefaultLogger) {
logger.Infof("Unsubscribing from topic: %s", sub.Topic())
}
sub.Unsubscribe()
}
@ -852,8 +852,8 @@ func (g *grpcServer) Start() error {
return err
}
if logger.V(logger.DebugLevel, logger.DefaultLogger) {
logger.Debugf("Broker [%s] Connected to %s", config.Broker.String(), config.Broker.Address())
if logger.V(logger.InfoLevel, logger.DefaultLogger) {
logger.Infof("Broker [%s] Connected to %s", config.Broker.String(), config.Broker.Address())
}
}
@ -930,8 +930,8 @@ func (g *grpcServer) Start() error {
// close transport
ch <- nil
if logger.V(logger.DebugLevel, logger.DefaultLogger) {
logger.Debugf("Broker [%s] Disconnected from %s", config.Broker.String(), config.Broker.Address())
if logger.V(logger.InfoLevel, logger.DefaultLogger) {
logger.Infof("Broker [%s] Disconnected from %s", config.Broker.String(), config.Broker.Address())
}
// disconnect broker
if err := config.Broker.Disconnect(); err != nil {

View File

@ -630,8 +630,8 @@ func (s *rpcServer) Register() error {
s.RUnlock()
if !registered {
if logger.V(logger.DebugLevel, logger.DefaultLogger) {
log.Debugf("Registry [%s] Registering node: %s", config.Registry.String(), node.Id)
if logger.V(logger.InfoLevel, logger.DefaultLogger) {
log.Infof("Registry [%s] Registering node: %s", config.Registry.String(), node.Id)
}
}
@ -684,8 +684,8 @@ func (s *rpcServer) Register() error {
if err != nil {
return err
}
if logger.V(logger.DebugLevel, logger.DefaultLogger) {
log.Debugf("Subscribing to topic: %s", sub.Topic())
if logger.V(logger.InfoLevel, logger.DefaultLogger) {
log.Infof("Subscribing to topic: %s", sub.Topic())
}
s.subscribers[sb] = []broker.Subscriber{sub}
}
@ -745,8 +745,8 @@ func (s *rpcServer) Deregister() error {
Nodes: []*registry.Node{node},
}
if logger.V(logger.DebugLevel, logger.DefaultLogger) {
log.Debugf("Registry [%s] Deregistering node: %s", config.Registry.String(), node.Id)
if logger.V(logger.InfoLevel, logger.DefaultLogger) {
log.Infof("Registry [%s] Deregistering node: %s", config.Registry.String(), node.Id)
}
if err := config.Registry.Deregister(service); err != nil {
return err
@ -770,8 +770,8 @@ func (s *rpcServer) Deregister() error {
for sb, subs := range s.subscribers {
for _, sub := range subs {
if logger.V(logger.DebugLevel, logger.DefaultLogger) {
log.Debugf("Unsubscribing %s from topic: %s", node.Id, sub.Topic())
if logger.V(logger.InfoLevel, logger.DefaultLogger) {
log.Infof("Unsubscribing %s from topic: %s", node.Id, sub.Topic())
}
sub.Unsubscribe()
}
@ -798,8 +798,8 @@ func (s *rpcServer) Start() error {
return err
}
if logger.V(logger.DebugLevel, logger.DefaultLogger) {
log.Debugf("Transport [%s] Listening on %s", config.Transport.String(), ts.Addr())
if logger.V(logger.InfoLevel, logger.DefaultLogger) {
log.Infof("Transport [%s] Listening on %s", config.Transport.String(), ts.Addr())
}
// swap address
@ -818,8 +818,8 @@ func (s *rpcServer) Start() error {
return err
}
if logger.V(logger.DebugLevel, logger.DefaultLogger) {
log.Debugf("Broker [%s] Connected to %s", bname, config.Broker.Address())
if logger.V(logger.InfoLevel, logger.DefaultLogger) {
log.Infof("Broker [%s] Connected to %s", bname, config.Broker.Address())
}
// use RegisterCheck func before register
@ -940,8 +940,8 @@ func (s *rpcServer) Start() error {
// close transport listener
ch <- ts.Close()
if logger.V(logger.DebugLevel, logger.DefaultLogger) {
log.Debugf("Broker [%s] Disconnected from %s", bname, config.Broker.Address())
if logger.V(logger.InfoLevel, logger.DefaultLogger) {
log.Infof("Broker [%s] Disconnected from %s", bname, config.Broker.Address())
}
// disconnect the broker
if err := config.Broker.Disconnect(); err != nil {