diff --git a/scnserver/api/ginresp/wrapper.go b/scnserver/api/ginresp/wrapper.go index 8df212c..d7b339a 100644 --- a/scnserver/api/ginresp/wrapper.go +++ b/scnserver/api/ginresp/wrapper.go @@ -68,6 +68,12 @@ func Wrap(rlacc RequestLogAcceptor, fn WHandlerFunc) gin.HandlerFunc { if scn.Conf.ReqLogEnabled { rlacc.InsertRequestLog(createRequestLog(g, t0, ctr, wrap, nil)) } + + statuscode := wrap.Statuscode() + if statuscode/100 != 2 { + log.Warn().Str("url", g.Request.Method+"::"+g.Request.URL.String()).Msg(fmt.Sprintf("Request failed with statuscode %d", statuscode)) + } + wrap.Write(g) } diff --git a/scnserver/api/handler/apiUser.go b/scnserver/api/handler/apiUser.go index f21b401..8ff71a5 100644 --- a/scnserver/api/handler/apiUser.go +++ b/scnserver/api/handler/apiUser.go @@ -5,7 +5,9 @@ import ( "blackforestbytes.com/simplecloudnotifier/api/ginresp" "blackforestbytes.com/simplecloudnotifier/models" "database/sql" + "fmt" "github.com/gin-gonic/gin" + "github.com/rs/zerolog/log" "gogs.mikescher.com/BlackForestBytes/goext/langext" "net/http" ) @@ -113,6 +115,8 @@ func (h APIHandler) CreateUser(g *gin.Context) ginresp.HTTPResponse { return ginresp.APIError(g, 500, apierr.DATABASE_ERROR, "Failed to create read-key in db", err) } + log.Info().Msg(fmt.Sprintf("Sucessfully created new user %s (client: %v)", userobj.UserID, b.NoClient)) + if b.NoClient { return ctx.FinishSuccess(ginresp.JSON(http.StatusOK, userobj.JSONWithClients(make([]models.Client, 0), adminKey, sendKey, readKey))) } else { diff --git a/scnserver/api/handler/message.go b/scnserver/api/handler/message.go index 452e28e..d81e27e 100644 --- a/scnserver/api/handler/message.go +++ b/scnserver/api/handler/message.go @@ -10,6 +10,7 @@ import ( "database/sql" "fmt" "github.com/gin-gonic/gin" + "github.com/rs/zerolog/log" "gogs.mikescher.com/BlackForestBytes/goext/dataext" "gogs.mikescher.com/BlackForestBytes/goext/langext" "gogs.mikescher.com/BlackForestBytes/goext/mathext" @@ -263,6 +264,8 @@ func (h MessageHandler) sendMessageInternal(g *gin.Context, ctx *logic.AppContex return nil, langext.Ptr(ginresp.SendAPIError(g, 500, apierr.DATABASE_ERROR, hl.NONE, "Failed to inc token msg-counter", err)) } + log.Info().Msg(fmt.Sprintf("Sending new notification %s for user %s", msg.MessageID, UserID)) + for _, sub := range subscriptions { clients, err := h.database.ListClients(ctx, sub.SubscriberUserID) if err != nil { diff --git a/scnserver/push/firebase.go b/scnserver/push/firebase.go index 0631585..4d9c8e5 100644 --- a/scnserver/push/firebase.go +++ b/scnserver/push/firebase.go @@ -127,5 +127,7 @@ func (fb FirebaseConnector) SendNotification(ctx context.Context, client models. return "", err } + log.Info().Msg(fmt.Sprintf("Sucessfully pushed notification %s", msg.MessageID)) + return respBody.Name, nil }