-
Notifications
You must be signed in to change notification settings - Fork 14
/
error_logger.go
39 lines (33 loc) · 1.11 KB
/
error_logger.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package registry
import (
"github.com/latolukasz/beeorm"
"github.com/sarulabs/di"
"github.com/coretrix/hitrix/service"
"github.com/coretrix/hitrix/service/component/app"
errorlogger "github.com/coretrix/hitrix/service/component/error_logger"
"github.com/coretrix/hitrix/service/component/sentry"
"github.com/coretrix/hitrix/service/component/slack"
)
func ServiceProviderErrorLogger() *service.DefinitionGlobal {
return &service.DefinitionGlobal{
Name: service.ErrorLoggerService,
Build: func(ctn di.Container) (interface{}, error) {
var sentryService sentry.ISentry
var slackAPIService slack.Slack
sentryServiceInterface, err := ctn.SafeGet(service.SentryService)
if err == nil {
sentryService = sentryServiceInterface.(sentry.ISentry)
}
slackAPIServiceInterface, err := ctn.SafeGet(service.SlackService)
if err == nil {
slackAPIService = slackAPIServiceInterface.(slack.Slack)
}
return errorlogger.NewRedisErrorLogger(
ctn.Get(service.AppService).(*app.App),
ctn.Get(service.ORMEngineGlobalService).(*beeorm.Engine),
slackAPIService,
sentryService,
), nil
},
}
}