-
Notifications
You must be signed in to change notification settings - Fork 0
/
logger_injector.go
40 lines (33 loc) · 949 Bytes
/
logger_injector.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
40
package inject
import (
"reflect"
"github.com/shima-park/lotus/pkg/common/log"
)
type loggerInjector struct {
where string
Injector
}
func NewLoggerInjector(where string, injector Injector) Injector {
return &loggerInjector{
where: where,
Injector: injector,
}
}
func (i *loggerInjector) Map(value interface{}, name string) TypeMapper {
log.Info("%s Map type: %s, name: %s to injector",
i.where, reflect.TypeOf(value), name)
i.Injector.Map(value, name)
return i
}
func (i *loggerInjector) MapTo(value interface{}, name string, ifacePtr interface{}) TypeMapper {
log.Info("%s MapTo type: %s, name: %s to injector",
i.where, reflect.TypeOf(ifacePtr), name)
i.Injector.MapTo(value, name, ifacePtr)
return i
}
func (i *loggerInjector) Set(typ reflect.Type, name string, value reflect.Value) TypeMapper {
log.Info("%s Set type: %s, name: %s to injector",
i.where, typ, name)
i.Injector.Set(typ, name, value)
return i
}