package
Version:
v1.0.0
Opens a new window with list of versions in this module.
Published: Jan 2, 2022
License: MIT
Opens a new window with license information.
Imports: 5
Opens a new window with list of imports.
Imported by: 0
Opens a new window with list of known importers.
README
¶
sentrusgin
Example
import (
"github.com/orandin/sentrus"
sentrusgin "github.com/orandin/sentrus/gin"
)
// Set up Sentry here
// Add hook
logrus.AddHook(sentrus.NewHook(
[]logrus.Level{logrus.WarnLevel, logrus.ErrorLevel},
sentrus.WithCustomCaptureLog(sentrusgin.CaptureLog),
))
app := gin.Default()
app.Use(func(ctx *gin.Context) {
if hub := sentrygin.GetHubFromContext(ctx); hub != nil {
hub.Scope().SetTag("someRandomTag", "maybeYouNeedIt")
}
ctx.Next()
})
app.GET("/", func(ctx *gin.Context) {
logHandler := logrus.WithContext(ctx) // Inject gin.Context into logrus.Entry
logHandler.Warn("It's a test")
ctx.Status(http.StatusOK)
})
app.GET("/foo", func(ctx *gin.Context) {
logHandler := logrus.WithContext(ctx)
logHandler.WithError(fmt.Errorf("test error")).Warn("It's a test with error")
ctx.Status(http.StatusOK)
})
app.Run(":3000")
Documentation
¶
Source Files
¶
Click to show internal directories.
Click to hide internal directories.