mirror of
https://github.com/elyby/chrly.git
synced 2024-12-24 14:09:56 +05:30
34 lines
647 B
Go
34 lines
647 B
Go
package di
|
|
|
|
import (
|
|
"github.com/defval/di"
|
|
"github.com/getsentry/raven-go"
|
|
"github.com/spf13/viper"
|
|
|
|
"ely.by/chrly/internal/version"
|
|
)
|
|
|
|
var loggerDiOptions = di.Options(
|
|
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())
|
|
|
|
raven.DefaultClient = ravenClient
|
|
|
|
return ravenClient, nil
|
|
}
|