@@ -105,7 +105,7 @@ func (c *controlConn) heartBeat() {
105105
106106 resp , err := c .writeFrame (& writeOptionsFrame {})
107107 if err != nil {
108- c .session .logger .Debug ("control connection heartbeat failed: %v." , NewLogField ("err" , err . Error () ))
108+ c .session .logger .Debug ("control connection heartbeat failed: %v." , newLogFieldError ("err" , err ))
109109 goto reconn
110110 }
111111
@@ -115,10 +115,10 @@ func (c *controlConn) heartBeat() {
115115 sleepTime = 5 * time .Second
116116 continue
117117 case error :
118- c .session .logger .Debug ("control connection heartbeat failed: %v." , NewLogField ("err" , actualResp . Error () ))
118+ c .session .logger .Debug ("control connection heartbeat failed: %v." , newLogFieldError ("err" , actualResp ))
119119 goto reconn
120120 default :
121- c .session .logger .Error ("unknown frame in response to options: %v" , NewLogField ("frame_type" , fmt .Sprintf ("%T" , resp )))
121+ c .session .logger .Error ("unknown frame in response to options: %v" , newLogFieldString ("frame_type" , fmt .Sprintf ("%T" , resp )))
122122 }
123123
124124 reconn:
@@ -247,18 +247,18 @@ func (c *controlConn) discoverProtocol(hosts []*HostInfo) (int, error) {
247247
248248 if err == nil {
249249 c .session .logger .Debug ("discovered protocol version %v using host %v (%s)." ,
250- NewLogField ("protocol_version" , connCfg .ProtoVersion ), NewLogField ("host_addr" , host .ConnectAddress ()), NewLogField ("host_id" , host .HostID ()))
250+ newLogFieldInt ("protocol_version" , connCfg .ProtoVersion ), newLogFieldIp ("host_addr" , host .ConnectAddress ()), newLogFieldString ("host_id" , host .HostID ()))
251251 return connCfg .ProtoVersion , nil
252252 }
253253
254254 if proto := parseProtocolFromError (err ); proto > 0 {
255255 c .session .logger .Debug ("discovered protocol version %v using host %v (%s)." ,
256- NewLogField ("protocol_version" , proto ), NewLogField ("host_addr" , host .ConnectAddress ()), NewLogField ("host_id" , host .HostID ()))
256+ newLogFieldInt ("protocol_version" , proto ), newLogFieldIp ("host_addr" , host .ConnectAddress ()), newLogFieldString ("host_id" , host .HostID ()))
257257 return proto , nil
258258 }
259259
260260 c .session .logger .Debug ("failed to discover protocol version using host %v (%v): %v." ,
261- NewLogField ("host_addr" , host .ConnectAddress ()), NewLogField ("host_id" , host .HostID ()), NewLogField ("err" , err . Error () ))
261+ newLogFieldIp ("host_addr" , host .ConnectAddress ()), newLogFieldString ("host_id" , host .HostID ()), newLogFieldError ("err" , err ))
262262 }
263263
264264 return 0 , err
@@ -282,21 +282,21 @@ func (c *controlConn) connect(hosts []*HostInfo) error {
282282 conn , err = c .session .dial (c .session .ctx , host , & cfg , c )
283283 if err != nil {
284284 c .session .logger .Info ("unable to dial control conn %s:%v (%s): %v" ,
285- NewLogField ("host_addr" , host .ConnectAddress ()),
286- NewLogField ("port" , host .Port ()),
287- NewLogField ("host_id" , host .HostID ()),
288- NewLogField ("err" , err . Error () ))
285+ newLogFieldIp ("host_addr" , host .ConnectAddress ()),
286+ newLogFieldInt ("port" , host .Port ()),
287+ newLogFieldString ("host_id" , host .HostID ()),
288+ newLogFieldError ("err" , err ))
289289 continue
290290 }
291291 err = c .setupConn (conn )
292292 if err == nil {
293293 break
294294 }
295295 c .session .logger .Info ("unable setup control conn %v:%v (%s): %v" ,
296- NewLogField ("host_addr" , host .ConnectAddress ()),
297- NewLogField ("port" , host .Port ()),
298- NewLogField ("host_id" , host .HostID ()),
299- NewLogField ("err" , err . Error () ))
296+ newLogFieldIp ("host_addr" , host .ConnectAddress ()),
297+ newLogFieldInt ("port" , host .Port ()),
298+ newLogFieldString ("host_id" , host .HostID ()),
299+ newLogFieldError ("err" , err ))
300300 conn .Close ()
301301 conn = nil
302302 }
@@ -334,7 +334,7 @@ func (c *controlConn) setupConn(conn *Conn) error {
334334
335335 if ! exists {
336336 c .session .logger .Info ("adding host %v (%v)." ,
337- NewLogField ("host_addr" , host .ConnectAddress (). String ()), NewLogField ("host_id" , host .HostID ()))
337+ newLogFieldIp ("host_addr" , host .ConnectAddress ()), newLogFieldString ("host_id" , host .HostID ()))
338338 }
339339
340340 if err := c .registerEvents (conn ); err != nil {
@@ -349,7 +349,7 @@ func (c *controlConn) setupConn(conn *Conn) error {
349349 c .conn .Store (ch )
350350
351351 c .session .logger .Info ("control connection connected to %v (%s)." ,
352- NewLogField ("host_addr" , host .ConnectAddress (). String ()), NewLogField ("host_id" , host .HostID ()))
352+ newLogFieldIp ("host_addr" , host .ConnectAddress ()), newLogFieldString ("host_id" , host .HostID ()))
353353
354354 if c .session .initialized () {
355355 // We connected to control conn, so add the connect the host in pool as well.
@@ -411,14 +411,14 @@ func (c *controlConn) reconnect() {
411411
412412 if err != nil {
413413 c .session .logger .Error ("unable to reconnect control connection: %v" ,
414- NewLogField ("err" , err . Error () ))
414+ newLogFieldError ("err" , err ))
415415 return
416416 }
417417
418418 err = c .session .refreshRing ()
419419 if err != nil {
420420 c .session .logger .Warning ("unable to refresh ring: %v" ,
421- NewLogField ("err" , err . Error () ))
421+ newLogFieldError ("err" , err ))
422422 }
423423}
424424
@@ -448,7 +448,7 @@ func (c *controlConn) attemptReconnect() (*Conn, error) {
448448 return conn , err
449449 }
450450
451- c .session .logger .Error ("unable to connect to any ring node, control connection falling back to initial contact points: %v" , NewLogField ("err" , err . Error () ))
451+ c .session .logger .Error ("unable to connect to any ring node, control connection falling back to initial contact points: %v" , newLogFieldError ("err" , err ))
452452 // Fallback to initial contact points, as it may be the case that all known initialHosts
453453 // changed their IPs while keeping the same hostname(s).
454454 initialHosts , resolvErr := addrsToHosts (c .session .cfg .Hosts , c .session .cfg .Port , c .session .logger )
@@ -466,21 +466,21 @@ func (c *controlConn) attemptReconnectToAnyOfHosts(hosts []*HostInfo) (*Conn, er
466466 conn , err = c .session .connect (c .session .ctx , host , c )
467467 if err != nil {
468468 c .session .logger .Info ("unable to dial control conn %s:%v (%s): %v" ,
469- NewLogField ("host_addr" , host .ConnectAddress ()),
470- NewLogField ("port" , host .Port ()),
471- NewLogField ("host_id" , host .HostID ()),
472- NewLogField ("err" , err . Error () ))
469+ newLogFieldIp ("host_addr" , host .ConnectAddress ()),
470+ newLogFieldInt ("port" , host .Port ()),
471+ newLogFieldString ("host_id" , host .HostID ()),
472+ newLogFieldError ("err" , err ))
473473 continue
474474 }
475475 err = c .setupConn (conn )
476476 if err == nil {
477477 break
478478 }
479479 c .session .logger .Info ("unable setup control conn %v:%v (%s): %v" ,
480- NewLogField ("host_addr" , host .ConnectAddress ()),
481- NewLogField ("port" , host .Port ()),
482- NewLogField ("host_id" , host .HostID ()),
483- NewLogField ("err" , err . Error () ))
480+ newLogFieldIp ("host_addr" , host .ConnectAddress ()),
481+ newLogFieldInt ("port" , host .Port ()),
482+ newLogFieldString ("host_id" , host .HostID ()),
483+ newLogFieldError ("err" , err ))
484484 conn .Close ()
485485 conn = nil
486486 }
@@ -501,9 +501,9 @@ func (c *controlConn) HandleError(conn *Conn, err error, closed bool) {
501501 }
502502
503503 c .session .logger .Info ("control connection error %v (%s): %v" ,
504- NewLogField ("host_addr" , conn .host .ConnectAddress (). String ()),
505- NewLogField ("host_id" , conn .host .HostID ()),
506- NewLogField ("err" , err . Error () ))
504+ newLogFieldIp ("host_addr" , conn .host .ConnectAddress ()),
505+ newLogFieldString ("host_id" , conn .host .HostID ()),
506+ newLogFieldError ("err" , err ))
507507
508508 c .reconnect ()
509509}
@@ -568,7 +568,7 @@ func (c *controlConn) query(statement string, values ...interface{}) (iter *Iter
568568
569569 if iter .err != nil {
570570 c .session .logger .Warning ("control: error executing %v: %v" ,
571- NewLogField ("statement" , statement ), NewLogField ("err" , iter .err . Error () ))
571+ newLogFieldString ("statement" , statement ), newLogFieldError ("err" , iter .err ))
572572 }
573573
574574 q .AddAttempts (1 , c .getConn ().host )
0 commit comments