@@ -137,7 +137,7 @@ type balancer struct {
137137func (b * balancer ) watchAddrUpdates (w naming.Watcher , ch chan []remoteBalancerInfo ) error {
138138 updates , err := w .Next ()
139139 if err != nil {
140- grpclog .Printf ("grpclb: failed to get next addr update from watcher: %v" , err )
140+ grpclog .Warningf ("grpclb: failed to get next addr update from watcher: %v" , err )
141141 return err
142142 }
143143 b .mu .Lock ()
@@ -162,21 +162,21 @@ func (b *balancer) watchAddrUpdates(w naming.Watcher, ch chan []remoteBalancerIn
162162 md , ok := update .Metadata .(* AddrMetadataGRPCLB )
163163 if ! ok {
164164 // TODO: Revisit the handling here and may introduce some fallback mechanism.
165- grpclog .Printf ("The name resolution contains unexpected metadata %v" , update .Metadata )
165+ grpclog .Errorf ("The name resolution contains unexpected metadata %v" , update .Metadata )
166166 continue
167167 }
168168 switch md .AddrType {
169169 case Backend :
170170 // TODO: Revisit the handling here and may introduce some fallback mechanism.
171- grpclog .Printf ("The name resolution does not give grpclb addresses" )
171+ grpclog .Errorf ("The name resolution does not give grpclb addresses" )
172172 continue
173173 case GRPCLB :
174174 b .rbs = append (b .rbs , remoteBalancerInfo {
175175 addr : update .Addr ,
176176 name : md .ServerName ,
177177 })
178178 default :
179- grpclog .Printf ("Received unknow address type %d" , md .AddrType )
179+ grpclog .Errorf ("Received unknow address type %d" , md .AddrType )
180180 continue
181181 }
182182 case naming .Delete :
@@ -188,7 +188,7 @@ func (b *balancer) watchAddrUpdates(w naming.Watcher, ch chan []remoteBalancerIn
188188 }
189189 }
190190 default :
191- grpclog .Println ("Unknown update.Op " , update .Op )
191+ grpclog .Errorf ("Unknown update.Op %v " , update .Op )
192192 }
193193 }
194194 // TODO: Fall back to the basic round-robin load balancing if the resulting address is
@@ -299,7 +299,7 @@ func (b *balancer) sendLoadReport(s *balanceLoadClientStream, interval time.Dura
299299 ClientStats : & stats ,
300300 },
301301 }); err != nil {
302- grpclog .Printf ("grpclb: failed to send load report: %v" , err )
302+ grpclog .Errorf ("grpclb: failed to send load report: %v" , err )
303303 return
304304 }
305305 }
@@ -310,7 +310,7 @@ func (b *balancer) callRemoteBalancer(lbc *loadBalancerClient, seq int) (retry b
310310 defer cancel ()
311311 stream , err := lbc .BalanceLoad (ctx )
312312 if err != nil {
313- grpclog .Printf ("grpclb: failed to perform RPC to the remote balancer %v" , err )
313+ grpclog .Errorf ("grpclb: failed to perform RPC to the remote balancer %v" , err )
314314 return
315315 }
316316 b .mu .Lock ()
@@ -327,25 +327,25 @@ func (b *balancer) callRemoteBalancer(lbc *loadBalancerClient, seq int) (retry b
327327 },
328328 }
329329 if err := stream .Send (initReq ); err != nil {
330- grpclog .Printf ("grpclb: failed to send init request: %v" , err )
330+ grpclog .Errorf ("grpclb: failed to send init request: %v" , err )
331331 // TODO: backoff on retry?
332332 return true
333333 }
334334 reply , err := stream .Recv ()
335335 if err != nil {
336- grpclog .Printf ("grpclb: failed to recv init response: %v" , err )
336+ grpclog .Errorf ("grpclb: failed to recv init response: %v" , err )
337337 // TODO: backoff on retry?
338338 return true
339339 }
340340 initResp := reply .GetInitialResponse ()
341341 if initResp == nil {
342- grpclog .Println ("grpclb: reply from remote balancer did not include initial response." )
342+ grpclog .Errorf ("grpclb: reply from remote balancer did not include initial response." )
343343 return
344344 }
345345 // TODO: Support delegation.
346346 if initResp .LoadBalancerDelegate != "" {
347347 // delegation
348- grpclog .Println ("TODO: Delegation is not supported yet." )
348+ grpclog .Errorf ("TODO: Delegation is not supported yet." )
349349 return
350350 }
351351 streamDone := make (chan struct {})
@@ -360,7 +360,7 @@ func (b *balancer) callRemoteBalancer(lbc *loadBalancerClient, seq int) (retry b
360360 for {
361361 reply , err := stream .Recv ()
362362 if err != nil {
363- grpclog .Printf ("grpclb: failed to recv server list: %v" , err )
363+ grpclog .Errorf ("grpclb: failed to recv server list: %v" , err )
364364 break
365365 }
366366 b .mu .Lock ()
@@ -394,7 +394,7 @@ func (b *balancer) Start(target string, config BalancerConfig) error {
394394 w , err := b .r .Resolve (target )
395395 if err != nil {
396396 b .mu .Unlock ()
397- grpclog .Printf ("grpclb: failed to resolve address: %v, err: %v" , target , err )
397+ grpclog .Errorf ("grpclb: failed to resolve address: %v, err: %v" , target , err )
398398 return err
399399 }
400400 b .w = w
@@ -404,7 +404,7 @@ func (b *balancer) Start(target string, config BalancerConfig) error {
404404 go func () {
405405 for {
406406 if err := b .watchAddrUpdates (w , balancerAddrsCh ); err != nil {
407- grpclog .Printf ("grpclb: the naming watcher stops working due to %v.\n " , err )
407+ grpclog .Warningf ("grpclb: the naming watcher stops working due to %v.\n " , err )
408408 close (balancerAddrsCh )
409409 return
410410 }
@@ -495,7 +495,7 @@ func (b *balancer) Start(target string, config BalancerConfig) error {
495495 if creds := config .DialCreds ; creds != nil {
496496 if rb .name != "" {
497497 if err := creds .OverrideServerName (rb .name ); err != nil {
498- grpclog .Printf ("grpclb: failed to override the server name in the credentials: %v" , err )
498+ grpclog .Warningf ("grpclb: failed to override the server name in the credentials: %v" , err )
499499 continue
500500 }
501501 }
@@ -510,7 +510,7 @@ func (b *balancer) Start(target string, config BalancerConfig) error {
510510 ccError = make (chan struct {})
511511 cc , err = Dial (rb .addr , dopts ... )
512512 if err != nil {
513- grpclog .Printf ("grpclb: failed to setup a connection to the remote balancer %v: %v" , rb .addr , err )
513+ grpclog .Warningf ("grpclb: failed to setup a connection to the remote balancer %v: %v" , rb .addr , err )
514514 close (ccError )
515515 continue
516516 }
0 commit comments