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