完善exceptionless

This commit is contained in:
suguo.yao 2022-09-16 10:10:19 +08:00
parent 25515fd266
commit 0c5879b6d3
1 changed files with 6 additions and 3 deletions

View File

@ -15,6 +15,7 @@ var config map[string]interface{} = nil
type Config struct {
ApiKey string
ServerURL string
ProgramName string
UpdateSettingsWhenIdleInterval int32
}
@ -134,13 +135,15 @@ func AddData(event Event, data map[string]interface{}) Event {
return event
}
func SubmitAppError(source string, reqid *string, err error) string {
func SubmitAppError(funcName string, proc string, reqid *string, err error) string {
referenceID := uuid.Must(uuid.NewUUID()).String()
if reqid != nil {
referenceID = *reqid
}
errorMap := map[string]interface{}{}
errorMap["function"] = funcName
errorMap["type"] = "error"
errorMap["message"] = err.Error()
errorMap["date"] = time.Now().Format(time.RFC3339)
@ -148,10 +151,10 @@ func SubmitAppError(source string, reqid *string, err error) string {
data["@simple_error"] = errorMap
var event = Event{
EventType: "error",
Message: err.Error(),
Message: proc,
Data: data,
ReferenceID: referenceID,
Source: source,
Source: conf.ProgramName,
}
json, err := json.Marshal(event)
if err != nil {