MCPcopy
hub / github.com/keploy/keploy / attachLogFileToSentry

Function attachLogFileToSentry

utils/utils.go:414–435  ·  view source on GitHub ↗
(logger *zap.Logger, logFilePath string)

Source from the content-addressed store, hash-verified

412}
413
414func attachLogFileToSentry(logger *zap.Logger, logFilePath string) error {
415 file, err := os.Open(logFilePath)
416 if err != nil {
417 return fmt.Errorf("error opening log file: %s", err.Error())
418 }
419 defer func() {
420 if err := file.Close(); err != nil {
421 LogError(logger, err, "Error closing log file")
422 }
423 }()
424
425 content, err := io.ReadAll(file)
426 if err != nil {
427 return fmt.Errorf("error reading log file: %s", err.Error())
428 }
429
430 sentry.ConfigureScope(func(scope *sentry.Scope) {
431 scope.SetExtra("logfile", string(content))
432 })
433 sentry.Flush(time.Second * 5)
434 return nil
435}
436
437// HandleRecovery handles the common logic for recovering from a panic.
438func HandleRecovery(logger *zap.Logger, r interface{}, errMsg string) {

Callers 1

HandleRecoveryFunction · 0.85

Calls 4

LogErrorFunction · 0.85
FlushMethod · 0.80
CloseMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected