Add caller skip to improve the log for segcore error (#25710)

Signed-off-by: yah01 <yang.cen@zilliz.com>
pull/25706/head
yah01 2023-07-18 19:54:57 +08:00 committed by GitHub
parent 9fe62cb5f3
commit 079cd9dc70
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 2 deletions

View File

@ -32,6 +32,7 @@ import (
"github.com/cockroachdb/errors"
"github.com/golang/protobuf/proto"
"go.uber.org/zap"
"github.com/milvus-io/milvus-proto/go-api/v2/commonpb"
"github.com/milvus-io/milvus/pkg/log"
@ -51,8 +52,9 @@ func HandleCStatus(status *C.CStatus, extraInfo string) error {
errorMsg := C.GoString(status.error_msg)
defer C.free(unsafe.Pointer(status.error_msg))
finalMsg := fmt.Sprintf("[%s] %s", errorName, errorMsg)
logMsg := fmt.Sprintf("%s, C Runtime Exception: %s\n", extraInfo, finalMsg)
finalMsg := fmt.Sprintf("%s: %s", errorName, errorMsg)
logMsg := fmt.Sprintf("%s, segcore error: %s\n", extraInfo, finalMsg)
log := log.With().WithOptions(zap.AddCallerSkip(1))
log.Warn(logMsg)
return errors.New(finalMsg)
}