Skip to content

Commit

Permalink
fixed gorm not logging via logrus => this not getting to sentry or no…
Browse files Browse the repository at this point in the history
…t being printed as json
  • Loading branch information
CommanderStorm committed Sep 14, 2023
1 parent 6f39d2f commit 4f64a8c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions server/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ require (
github.com/makasim/sentryhook v0.4.2
github.com/microcosm-cc/bluemonday v1.0.25
github.com/mmcdole/gofeed v1.2.1
github.com/onrik/gorm-logrus v0.5.0
github.com/satori/go.uuid v1.2.0
github.com/sirupsen/logrus v1.9.3
github.com/soheilhy/cmux v0.1.5
Expand Down
2 changes: 2 additions & 0 deletions server/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,8 @@ github.com/neelance/sourcemap v0.0.0-20200213170602-2833bce08e4c/go.mod h1:Qr6/a
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=
github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU=
github.com/onrik/gorm-logrus v0.5.0 h1:JKeFH+j8AIpCDtsxHgteMtQeZtJ1k+M6UlUXwfkd2+o=
github.com/onrik/gorm-logrus v0.5.0/go.mod h1:QSx05I0N2V7M7ehsThQQmQE6K1H+drVYU2NQVNko4nw=
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk=
github.com/onsi/ginkgo v1.16.4/go.mod h1:dX+/inL/fNMqNlz0e9LfyB9TswhZpCVdJM/Z6Vvnwo0=
Expand Down
3 changes: 2 additions & 1 deletion server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"github.com/TUM-Dev/Campus-Backend/server/backend/migration"
"github.com/getsentry/sentry-go"
"github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
"github.com/onrik/gorm-logrus"
log "github.com/sirupsen/logrus"
"github.com/soheilhy/cmux"
"golang.org/x/sync/errgroup"
Expand Down Expand Up @@ -136,7 +137,7 @@ func setupDB() *gorm.DB {
conn = mysql.Open(dbHost)
}

db, err := gorm.Open(conn, &gorm.Config{})
db, err := gorm.Open(conn, &gorm.Config{Logger: gorm_logrus.New()})
if err != nil {
log.WithError(err).Panic("failed to connect database")
}
Expand Down

0 comments on commit 4f64a8c

Please sign in to comment.