Better logging
This commit is contained in:
parent
f1fe01f725
commit
909dd35960
@ -2,7 +2,6 @@ package middleware
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/TicketsBot/GoPanel/config"
|
|
||||||
"github.com/getsentry/sentry-go"
|
"github.com/getsentry/sentry-go"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
@ -14,13 +13,13 @@ func Logging(ctx *gin.Context) {
|
|||||||
|
|
||||||
statusCode := ctx.Writer.Status()
|
statusCode := ctx.Writer.Status()
|
||||||
|
|
||||||
if !config.Conf.Debug && statusCode >= 200 && statusCode <= 299 {
|
var level sentry.Level
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
level := sentry.LevelInfo
|
|
||||||
if statusCode >= 500 {
|
if statusCode >= 500 {
|
||||||
level = sentry.LevelError
|
level = sentry.LevelError
|
||||||
|
} else if statusCode >= 400 {
|
||||||
|
level = sentry.LevelWarning
|
||||||
|
} else {
|
||||||
|
level = sentry.LevelInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
body, _ := ioutil.ReadAll(ctx.Request.Body)
|
body, _ := ioutil.ReadAll(ctx.Request.Body)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user