Documentation ¶
Index ¶
- Constants
- Variables
- func BuildAndSendSentryEvent(tracker *Tracker)
- func BuildSentryEvent(tracker *Tracker) *sentry.Event
- func CE(ctx context.Context, err error, trackValues ...map[string]interface{})
- func CEI(ctx context.Context, err interface{}, trackValues ...map[string]interface{})
- func CERecover(ctx context.Context, trackValues ...map[string]interface{})
- func CERecoverError(ctx context.Context, errPointer *error, trackValues ...map[string]interface{})
- func CheckContext(ctx context.Context)
- func CheckTracker(tracker *Tracker)
- func GetTrackID(ctx context.Context) string
- func GinWithLogger() gin.HandlerFunc
- func GinWithRecover() gin.HandlerFunc
- func GinWithTracker() gin.HandlerFunc
- func InitAlog(version string, sentryUrl, sentryPublicKey string)
- func RandomBytes(length int) []byte
- func Recover(ctx context.Context)deprecated
- func SendSentryEvent(event *sentry.Event) error
- func TraceStack(ctx context.Context, e interface{}, trackValues ...map[string]interface{}) error
- func WithTracker(parent context.Context) (context.Context, context.CancelFunc)
- type Exception
- type ExceptionStack
- type Tracker
- type V
Constants ¶
View Source
const ( KeyTracker = "_alog_Tracker" KeyTrackID = "_alog_TrackID" GinHttpResponseHeader = "X-Track" )
Variables ¶
View Source
var ( ConfigAppVersion = "" ConfigSentryUrl = "" ConfigSentryPublicKey = "" )
View Source
var ERROR = log.New(os.Stdout, "[ERROR]", log.LstdFlags|log.Lshortfile)
View Source
var INFO = log.New(os.Stdout, "[INFO]", log.LstdFlags|log.Lshortfile)
View Source
var RECOVER = log.New(os.Stdout, "[RECOVER]", log.LstdFlags|log.Lshortfile)
Functions ¶
func BuildAndSendSentryEvent ¶
func BuildAndSendSentryEvent(tracker *Tracker)
func BuildSentryEvent ¶
func BuildSentryEvent(tracker *Tracker) *sentry.Event
func CEI ¶ added in v0.3.0
CEI 意思是 Check Error Interface,可以灵活处理interface{}。 建议不要用在 recover() 的情况,会丢失 panic() 的位置,请使用 CERecover 替代。 建议不要使用可比较值,否则可能与其他错误栈混在一起,最好用指针或者接口变量。
func CERecoverError ¶ added in v0.6.0
func CheckContext ¶
func CheckTracker ¶
func CheckTracker(tracker *Tracker)
func GetTrackID ¶
func GinWithLogger ¶
func GinWithLogger() gin.HandlerFunc
GinWithLogger returns gin.HandlerFunc, it should be used as a middleware. Compare to gin.Logger(), it prints "TrackerID" for each request in addition.
func GinWithRecover ¶
func GinWithRecover() gin.HandlerFunc
GinWithRecover returns gin.HandlerFunc, it should be used as a middleware. It recovers your server from panic, and record the error in Tracker (to handle it later).
func GinWithTracker ¶
func GinWithTracker() gin.HandlerFunc
GinWithTracker returns gin.HandlerFunc, it should be used as a middleware. It injects a Tracker to *gin.Context for each request.
func RandomBytes ¶
RandomBytes Generates random alphanumeric bytes.
func SendSentryEvent ¶
func SendSentryEvent(event *sentry.Event) error
func TraceStack ¶
func WithTracker ¶
Types ¶
type Exception ¶
type Exception struct { Error error Stacks []*ExceptionStack }
type ExceptionStack ¶
type Tracker ¶
type Tracker struct { ID string Exceptions []*Exception Request *sentry.Request // contains filtered or unexported fields }
func GetTracker ¶
func NewTracker ¶
func NewTracker() *Tracker
Click to show internal directories.
Click to hide internal directories.