-
Notifications
You must be signed in to change notification settings - Fork 13
/
error_logger.go
34 lines (30 loc) · 983 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/coretrix/hitrix/service"
"github.com/coretrix/hitrix/service/component/app"
errorlogger "github.com/coretrix/hitrix/service/component/error_logger"
slackapi "github.com/coretrix/hitrix/service/component/slack_api"
"github.com/sarulabs/di"
"github.com/summer-solutions/orm"
)
func ServiceProviderErrorLogger() *service.Definition {
return &service.Definition{
Name: service.ErrorLoggerService,
Global: true,
Build: func(ctn di.Container) (interface{}, error) {
slackAPIService, err := ctn.SafeGet(service.SlackAPIService)
if err == nil {
return errorlogger.NewRedisErrorLogger(
ctn.Get(service.AppService).(*app.App),
ctn.Get(service.ORMEngineGlobalService).(*orm.Engine),
slackAPIService.(*slackapi.SlackAPI),
), nil
}
return errorlogger.NewRedisErrorLogger(
ctn.Get(service.AppService).(*app.App),
ctn.Get(service.ORMEngineGlobalService).(*orm.Engine),
nil,
), nil
},
}
}