@@ -39,7 +39,7 @@ func NewHEPOutputer(serverAddr string) (*HEPOutputer, error) {
39
39
errCnt := 0
40
40
for n := range a {
41
41
if err := h .ConnectServer (n ); err != nil {
42
- logp .Err ("%v" , err )
42
+ logp .Err ("Error connecting to HEP server (%s): %v" , h . addr [ n ] , err )
43
43
errCnt ++
44
44
} else {
45
45
if config .Cfg .HEPBufferEnable {
@@ -52,7 +52,7 @@ func NewHEPOutputer(serverAddr string) (*HEPOutputer, error) {
52
52
}
53
53
}
54
54
if errCnt == l {
55
- return nil , fmt .Errorf ("cannot establish a connection" )
55
+ return nil , fmt .Errorf ("Cannot establish a connection" )
56
56
}
57
57
58
58
go h .Start ()
@@ -61,12 +61,13 @@ func NewHEPOutputer(serverAddr string) (*HEPOutputer, error) {
61
61
62
62
func (h * HEPOutputer ) Close (n int ) {
63
63
if err := h .client [n ].conn .Close (); err != nil {
64
- logp .Err ("cannnot close connection to %s: %v" , h .addr [n ], err )
64
+ logp .Err ("Cannot close connection to %s: %v" , h .addr [n ], err )
65
65
}
66
66
}
67
67
68
68
func (h * HEPOutputer ) ReConnect (n int ) (err error ) {
69
69
if err = h .ConnectServer (n ); err != nil {
70
+ logp .Err ("Error reconnecting to HEP server (%s): %v" , h .addr [n ], err )
70
71
return err
71
72
}
72
73
h .client [n ].writer .Reset (h .client [n ].conn )
@@ -154,7 +155,7 @@ func (h *HEPOutputer) Send(msg []byte) {
154
155
var err error
155
156
156
157
if h .client [n ].conn == nil || h .client [n ].writer == nil {
157
- logp .Debug ("connection is not up" , fmt .Sprintf ("index: %d, Len: %d, once: %v" , n , len (h .addr ), onceSent ))
158
+ logp .Debug ("Connection is not up" , fmt .Sprintf ("index: %d, Len: %d, once: %v" , n , len (h .addr ), onceSent ))
158
159
err = fmt .Errorf ("connection is broken" )
159
160
} else {
160
161
h .client [n ].writer .Write (msg )
@@ -216,13 +217,13 @@ func (h *HEPOutputer) copyHEPFileOut(n int) (int, error) {
216
217
217
218
defer func () {
218
219
if r := recover (); r != nil {
219
- logp .Err ("copy hep file out panic: %v, %v" , r , debug .Stack ())
220
+ logp .Err ("Copy hep file out panic: %v, %v" , r , debug .Stack ())
220
221
return
221
222
}
222
223
}()
223
224
224
225
if _ , err := os .Stat (config .Cfg .HEPBufferFile ); err != nil {
225
- logp .Debug ("file doesn't exists: " , config .Cfg .HEPBufferFile )
226
+ logp .Debug ("File doesn't exists: " , config .Cfg .HEPBufferFile )
226
227
return 1 , nil
227
228
}
228
229
@@ -233,15 +234,15 @@ func (h *HEPOutputer) copyHEPFileOut(n int) (int, error) {
233
234
}
234
235
235
236
if h .client [n ].conn == nil {
236
- logp .Err ("connection is not up...." )
237
- return 0 , fmt .Errorf ("connection is broken" )
237
+ logp .Err ("Connection is not up...." )
238
+ return 0 , fmt .Errorf ("Connection is broken" )
238
239
}
239
240
240
241
//Send Logged HEP upon reconnect out to backend
241
242
hl , err := h .client [n ].conn .Write (HEPFileData )
242
243
if err != nil {
243
244
promstats .HepFileFlushesError .Inc ()
244
- return 0 , fmt .Errorf ("bad write to socket" )
245
+ return 0 , fmt .Errorf ("Bad write to socket" )
245
246
}
246
247
247
248
err = h .client [n ].writer .Flush ()
@@ -268,40 +269,40 @@ func (h *HEPOutputer) copyHEPbufftoFile(inbytes []byte) (int64, error) {
268
269
269
270
defer func () {
270
271
if r := recover (); r != nil {
271
- logp .Err ("copy buffer to panic: %v,\n %s" , r , debug .Stack ())
272
+ logp .Err ("Copy buffer to panic: %v,\n %s" , r , debug .Stack ())
272
273
return
273
274
}
274
275
}()
275
276
276
277
if config .Cfg .HEPBufferDebug {
277
- logp .Err ("adding packet to BUFFER: %s\n " , string (inbytes ))
278
+ logp .Err ("Adding packet to BUFFER: %s\n " , string (inbytes ))
278
279
}
279
280
280
281
destination , err := os .OpenFile (config .Cfg .HEPBufferFile , os .O_APPEND | os .O_CREATE | os .O_WRONLY , 0666 )
281
282
if err != nil {
282
- logp .Err ("open HEP file error: %v\n " , err )
283
- return 0 , fmt .Errorf ("open HEP file error: %v" , err )
283
+ logp .Err ("Open HEP file error: %v\n " , err )
284
+ return 0 , fmt .Errorf ("Open HEP file error: %v" , err )
284
285
}
285
286
286
287
defer destination .Close ()
287
288
288
289
if config .Cfg .MaxBufferSizeBytes > 0 {
289
290
fi , err := destination .Stat ()
290
291
if err != nil {
291
- logp .Debug ("collector" , fmt .Sprintf ("couldn 't retrive stats from buffer file error: %v" , err .Error ()))
292
+ logp .Debug ("collector" , fmt .Sprintf ("Couldn 't retrive stats from buffer file error: %v" , err .Error ()))
292
293
return 0 , err
293
294
} else {
294
295
if fi .Size () >= config .Cfg .MaxBufferSizeBytes {
295
- logp .Debug ("collector" , fmt .Sprintln ("Buffer size has been excited error: Maxsize: " , config .Cfg .MaxBufferSizeBytes , " vs CurrentSize: " , fi .Size ()))
296
- return 0 , fmt .Errorf ("buffer size has been excited : %d" , fi .Size ())
296
+ logp .Debug ("collector" , fmt .Sprintln ("Buffer size has been exceeded error: Maxsize: " , config .Cfg .MaxBufferSizeBytes , " vs CurrentSize: " , fi .Size ()))
297
+ return 0 , fmt .Errorf ("Buffer size has been exceeded : %d" , fi .Size ())
297
298
}
298
299
}
299
300
}
300
301
301
302
nBytes , err := destination .Write (inbytes )
302
303
303
304
if err != nil {
304
- logp .Err ("file Send HEP from buffer to file error: %v" , err .Error ())
305
+ logp .Err ("File send HEP from buffer to file error: %v" , err .Error ())
305
306
return 0 , fmt .Errorf ("file Send HEP from buffer to file error: %v" , err .Error ())
306
307
} else {
307
308
logp .Debug ("collector" , " File Send HEP from buffer to file OK" )
0 commit comments