-
Notifications
You must be signed in to change notification settings - Fork 14
/
error_logger.go
34 lines (29 loc) · 958 Bytes
/
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
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/slack"
)
func ServiceProviderErrorLogger() *service.DefinitionGlobal {
return &service.DefinitionGlobal{
Name: service.ErrorLoggerService,
Build: func(ctn di.Container) (interface{}, error) {
slackAPIService, err := ctn.SafeGet(service.SlackService)
if err == nil {
return errorlogger.NewRedisErrorLogger(
ctn.Get(service.AppService).(*app.App),
ctn.Get(service.ORMEngineGlobalService).(*beeorm.Engine),
slackAPIService.(slack.Slack),
), nil
}
return errorlogger.NewRedisErrorLogger(
ctn.Get(service.AppService).(*app.App),
ctn.Get(service.ORMEngineGlobalService).(*beeorm.Engine),
nil,
), nil
},
}
}