56 lines
1.5 KiB
Go
56 lines
1.5 KiB
Go
package main
|
|
|
|
import (
|
|
"encoding/json"
|
|
"errors"
|
|
"fmt"
|
|
"time"
|
|
|
|
exceptionless "github.com/Exceptionless/Exceptionless.Go"
|
|
uuid "github.com/satori/go.uuid"
|
|
)
|
|
|
|
func main() {
|
|
//日志初始化
|
|
exceptionless.Configure(exceptionless.Exceptionless{
|
|
ApiKey: "QF5OrvQfYCSLX9FQQoKd4ruRawJKpD2S19VYSGud",
|
|
ServerURL: `http://192.168.0.33:5000/api/v2/`,
|
|
})
|
|
|
|
t := exceptionless.SubmitLog("demo for exceptionless is running...", "info")
|
|
fmt.Println(t)
|
|
exceptionless.SubmitLog("demo for exceptionless is running...", "error")
|
|
exceptionless.SubmitLog("demo for exceptionless is running...", "warn")
|
|
exceptionless.SubmitLog("demo for exceptionless is running...", "fatal")
|
|
exceptionless.SubmitLog("demo for exceptionless is running...", "debug")
|
|
|
|
referenceID := uuid.Must(uuid.NewV4())
|
|
event := &struct {
|
|
Event string
|
|
Message string
|
|
Date string
|
|
EventType string
|
|
ReferenceID uuid.UUID
|
|
}{
|
|
Event: "error",
|
|
EventType: "error",
|
|
Message: "aaaaaaaaaaaaaaaaaa",
|
|
Date: time.Now().Format(time.RFC3339),
|
|
ReferenceID: referenceID,
|
|
}
|
|
ret, _ := json.Marshal(event)
|
|
t2 := exceptionless.SubmitEvent(string(ret))
|
|
fmt.Println(t2)
|
|
|
|
// t3 := exceptionless.SubmitError(errors.Unwrap(errors.New("dasfasdfasdf")))
|
|
// fmt.Println(t3) //通不过error stack
|
|
|
|
//重定试试error
|
|
t3 := submitError(errors.New("sadfsdfasdfsdafasdf"))
|
|
fmt.Println(t3)
|
|
|
|
//自定义
|
|
t4 := exceptionless.SubmitEvent("asfasdfasdfasdfasd")
|
|
fmt.Println(t4)
|
|
}
|