@@ -84,7 +84,6 @@ type bolt3 struct {
84
84
bookmark string // Last bookmark
85
85
birthDate time.Time
86
86
log log.Logger
87
- logName string
88
87
receiveBufer []byte
89
88
sendBuffers [][]byte
90
89
}
@@ -101,7 +100,6 @@ func NewBolt3(serverName string, conn net.Conn, log log.Logger) *bolt3 {
101
100
unpacker : & packstream.Unpacker {},
102
101
birthDate : time .Now (),
103
102
log : log ,
104
- logName : "bolt3" ,
105
103
}
106
104
}
107
105
@@ -122,7 +120,7 @@ func (b *bolt3) appendMsg(tag packstream.StructTag, field ...interface{}) error
122
120
// At this point we do not know the state of what has been written to the chunks.
123
121
// Either we should support rolling back whatever that has been written or just
124
122
// bail out this session.
125
- b .log .Error (b . logName , b .logId , err )
123
+ b .log .Error (log . Bolt3 , b .logId , err )
126
124
b .state = bolt3_dead
127
125
return err
128
126
}
@@ -135,7 +133,7 @@ func (b *bolt3) sendMsg(tag packstream.StructTag, field ...interface{}) error {
135
133
return err
136
134
}
137
135
if err := b .chunker .send (b .conn ); err != nil {
138
- b .log .Error (b . logName , b .logId , err )
136
+ b .log .Error (log . Bolt3 , b .logId , err )
139
137
b .state = bolt3_dead
140
138
return err
141
139
}
@@ -146,14 +144,14 @@ func (b *bolt3) receiveMsg() (interface{}, error) {
146
144
var err error
147
145
b .receiveBufer , err = dechunkMessage (b .conn , b .receiveBufer )
148
146
if err != nil {
149
- b .log .Error (b . logName , b .logId , err )
147
+ b .log .Error (log . Bolt3 , b .logId , err )
150
148
b .state = bolt3_dead
151
149
return nil , err
152
150
}
153
151
154
152
msg , err := b .unpacker .UnpackStruct (b .receiveBufer , hydrate )
155
153
if err != nil {
156
- b .log .Error (b . logName , b .logId , err )
154
+ b .log .Error (log . Bolt3 , b .logId , err )
157
155
b .state = bolt3_dead
158
156
return nil , err
159
157
}
@@ -176,15 +174,15 @@ func (b *bolt3) receiveSuccess() (*successResponse, error) {
176
174
b .state = bolt3_failed
177
175
if v .Classification () == "ClientError" {
178
176
// These could include potentially large cypher statement, only log to debug
179
- b .log .Debugf (b . logName , b .logId , "%s" , v )
177
+ b .log .Debugf (log . Bolt3 , b .logId , "%s" , v )
180
178
} else {
181
- b .log .Error (b . logName , b .logId , v )
179
+ b .log .Error (log . Bolt3 , b .logId , v )
182
180
}
183
181
return nil , v
184
182
}
185
183
b .state = bolt3_dead
186
184
err = errors .New ("Expected success or database error" )
187
- b .log .Error (b . logName , b .logId , err )
185
+ b .log .Error (log . Bolt3 , b .logId , err )
188
186
return nil , err
189
187
}
190
188
@@ -225,7 +223,7 @@ func (b *bolt3) connect(auth map[string]interface{}, userAgent string) error {
225
223
226
224
// Transition into ready state
227
225
b .state = bolt3_ready
228
- b .log .Infof (b . logName , b .logId , "Connected" )
226
+ b .log .Infof (log . Bolt3 , b .logId , "Connected" )
229
227
return nil
230
228
}
231
229
@@ -307,7 +305,7 @@ func (b *bolt3) TxCommit(txh db.Handle) error {
307
305
if commitSuccess == nil {
308
306
b .state = bolt3_dead
309
307
err := errors .New (fmt .Sprintf ("Failed to parse commit response: %+v" , succRes ))
310
- b .log .Error (b . logName , b .logId , err )
308
+ b .log .Error (log . Bolt3 , b .logId , err )
311
309
return err
312
310
}
313
311
@@ -430,7 +428,7 @@ func (b *bolt3) run(cypher string, params map[string]interface{}, tx *internalTx
430
428
if runRes == nil {
431
429
b .state = bolt3_dead
432
430
err = errors .New (fmt .Sprintf ("Failed to parse RUN response: %+v" , res ))
433
- b .log .Error (b . logName , b .logId , err )
431
+ b .log .Error (log . Bolt3 , b .logId , err )
434
432
return nil , err
435
433
}
436
434
b .tfirst = runRes .t_first
@@ -448,11 +446,11 @@ func (b *bolt3) run(cypher string, params map[string]interface{}, tx *internalTx
448
446
}
449
447
450
448
func (b * bolt3 ) logError (err error ) {
451
- b .log .Error (b . logName , b .logId , err )
449
+ b .log .Error (log . Bolt3 , b .logId , err )
452
450
}
453
451
454
452
func (b * bolt3 ) logDebug (err error ) {
455
- b .log .Debugf (b . logName , b .logId , "%s" , err )
453
+ b .log .Debugf (log . Bolt3 , b .logId , "%s" , err )
456
454
}
457
455
458
456
func (b * bolt3 ) Run (
@@ -508,7 +506,7 @@ func (b *bolt3) Next(shandle db.Handle) (*db.Record, *db.Summary, error) {
508
506
if sum == nil {
509
507
b .state = bolt3_dead
510
508
err = errors .New ("Failed to parse summary" )
511
- b .log .Error (b . logName , b .logId , err )
509
+ b .log .Error (log . Bolt3 , b .logId , err )
512
510
return nil , nil , err
513
511
}
514
512
if b .state == bolt3_streamingtx {
@@ -530,15 +528,15 @@ func (b *bolt3) Next(shandle db.Handle) (*db.Record, *db.Summary, error) {
530
528
b .state = bolt3_failed
531
529
if x .Classification () == "ClientError" {
532
530
// These could include potentially large cypher statement, only log to debug
533
- b .log .Debugf (b . logName , b .logId , "%s" , x )
531
+ b .log .Debugf (log . Bolt3 , b .logId , "%s" , x )
534
532
} else {
535
- b .log .Error (b . logName , b .logId , x )
533
+ b .log .Error (log . Bolt3 , b .logId , x )
536
534
}
537
535
return nil , nil , x
538
536
default :
539
537
b .state = bolt3_dead
540
538
err = errors .New ("Unknown response" )
541
- b .log .Error (b . logName , b .logId , err )
539
+ b .log .Error (log . Bolt3 , b .logId , err )
542
540
return nil , nil , err
543
541
}
544
542
}
@@ -645,7 +643,7 @@ func (b *bolt3) GetRoutingTable(database string, context map[string]string) (*db
645
643
646
644
// Beware, could be called on another thread when driver is closed.
647
645
func (b * bolt3 ) Close () {
648
- b .log .Infof (b . logName , b .logId , "Disconnected" )
646
+ b .log .Infof (log . Bolt3 , b .logId , "Disconnected" )
649
647
if b .state != bolt3_dead {
650
648
b .sendMsg (msgGoodbye )
651
649
}
0 commit comments