2020-04-16 19:42:38 +03:00
|
|
|
package di
|
|
|
|
|
|
|
|
import (
|
2023-12-13 17:29:12 +01:00
|
|
|
"github.com/defval/di"
|
2020-04-16 19:42:38 +03:00
|
|
|
"github.com/getsentry/raven-go"
|
|
|
|
"github.com/spf13/viper"
|
|
|
|
|
2024-02-01 08:12:34 +01:00
|
|
|
"ely.by/chrly/internal/version"
|
2020-04-16 19:42:38 +03:00
|
|
|
)
|
|
|
|
|
2024-02-07 17:34:57 +01:00
|
|
|
var loggerDiOptions = di.Options(
|
2020-04-16 19:42:38 +03:00
|
|
|
di.Provide(newSentry),
|
|
|
|
)
|
|
|
|
|
|
|
|
func newSentry(config *viper.Viper) (*raven.Client, error) {
|
|
|
|
sentryAddr := config.GetString("sentry.dsn")
|
|
|
|
if sentryAddr == "" {
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
ravenClient, err := raven.New(sentryAddr)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
ravenClient.SetEnvironment("production")
|
|
|
|
ravenClient.SetDefaultLoggerName("sentry-watchdog-receiver")
|
|
|
|
ravenClient.SetRelease(version.Version())
|
|
|
|
|
2020-04-20 17:12:58 +03:00
|
|
|
raven.DefaultClient = ravenClient
|
|
|
|
|
2020-04-16 19:42:38 +03:00
|
|
|
return ravenClient, nil
|
|
|
|
}
|