fix: enable sentry when configured
This commit is contained in:
parent
085202c174
commit
d8df6d577e
@ -94,11 +94,14 @@ func prepareServices(c *cli.Context) *do.Injector {
|
||||
func wrap(f func(i *do.Injector) error) func(*cli.Context) error {
|
||||
return func(c *cli.Context) error {
|
||||
defer func() {
|
||||
if cmd.SentryDSN != "" {
|
||||
// only recover when sentry is enabled
|
||||
if r := recover(); r != nil {
|
||||
sentry.CaptureException(r.(error))
|
||||
sentry.Flush(time.Second * 2)
|
||||
slog.Printf("Panic Captured: %v", r)
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
injector := prepareServices(c)
|
||||
|
@ -1,6 +1,7 @@
|
||||
package log
|
||||
|
||||
import (
|
||||
"git.0x7f.app/WOJ/woj-server/cmd"
|
||||
"git.0x7f.app/WOJ/woj-server/internal/misc/config"
|
||||
"git.0x7f.app/WOJ/woj-server/pkg/utils"
|
||||
"github.com/TheZeroSlave/zapsentry"
|
||||
@ -48,7 +49,9 @@ func NewService(i *do.Injector) (Service, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if cmd.SentryDSN != "" {
|
||||
srv.logger = attachSentry(srv.logger)
|
||||
}
|
||||
|
||||
return srv, nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user