Skip to content

Commit 77fe91a

Browse files
authored
fix log with name (#17)
1 parent 52307b4 commit 77fe91a

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

internal/dix_inter/dix.go

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77

88
"github.com/pubgo/funk/assert"
99
"github.com/pubgo/funk/errors"
10-
"github.com/pubgo/funk/log"
1110
"github.com/pubgo/funk/recovery"
1211
"github.com/pubgo/funk/stack"
1312
)
@@ -58,7 +57,7 @@ func (x *Dix) evalProvider(typ outputType, opt Options) map[group][]value {
5857
}
5958

6059
if len(x.providers[typ]) == 0 {
61-
log.Warn().
60+
logger.Warn().
6261
Str("type", typ.String()).
6362
Str("kind", typ.Kind().String()).
6463
Msg("provider not found, please check whether the provider imports or type error")
@@ -69,7 +68,7 @@ func (x *Dix) evalProvider(typ outputType, opt Options) map[group][]value {
6968
x.objects[typ] = make(map[group][]value)
7069
}
7170

72-
log.Debug().
71+
logger.Debug().
7372
Str("type", typ.String()).
7473
Str("kind", typ.Kind().String()).
7574
Int("providers", len(x.providers[typ])).
@@ -92,7 +91,7 @@ func (x *Dix) evalProvider(typ outputType, opt Options) map[group][]value {
9291
for k, oo := range handleOutput(typ, fnCall[0]) {
9392
if n.output.isMap {
9493
if _, ok := objects[k]; ok {
95-
log.Info().
94+
logger.Info().
9695
Str("type", typ.String()).
9796
Str("key", k.String()).
9897
Msg("type value exists")
@@ -135,7 +134,7 @@ func (x *Dix) getValue(typ reflect.Type, opt Options, isMap, isList bool) reflec
135134
case isMap:
136135
valMap := x.evalProvider(typ, opt)
137136
if !opt.AllowValuesNull && len(valMap) == 0 {
138-
log.Panic().
137+
logger.Panic().
139138
Any("options", opt).
140139
Str("type", typ.String()).
141140
Any("providers", x.getProviderStack(typ)).
@@ -152,7 +151,7 @@ func (x *Dix) getValue(typ reflect.Type, opt Options, isMap, isList bool) reflec
152151
Detail: fmt.Sprintf("type=%s kind=%s allValues=%v", typ, typ.Kind(), valMap),
153152
}
154153

155-
log.Panic().Err(err).
154+
logger.Panic().Err(err).
156155
Any("options", opt).
157156
Any("values", valMap[defaultKey]).
158157
Any("providers", x.getProviderStack(typ)).
@@ -169,7 +168,7 @@ func (x *Dix) getValue(typ reflect.Type, opt Options, isMap, isList bool) reflec
169168
default:
170169
valMap := x.evalProvider(typ, opt)
171170
if valList, ok := valMap[defaultKey]; !ok || len(valList) == 0 {
172-
log.Panic().
171+
logger.Panic().
173172
Any("options", opt).
174173
Any("values", valMap[defaultKey]).
175174
Str("type", typ.String()).
@@ -185,7 +184,7 @@ func (x *Dix) getValue(typ reflect.Type, opt Options, isMap, isList bool) reflec
185184
Detail: fmt.Sprintf("type=%s kind=%s value=%v", typ, typ.Kind(), val.Interface()),
186185
}
187186

188-
log.Panic().Err(err).
187+
logger.Panic().Err(err).
189188
Any("options", opt).
190189
Any("values", valList).
191190
Any("providers", x.getProviderStack(typ)).
@@ -328,7 +327,7 @@ func (x *Dix) handleProvide(fnVal reflect.Value, out reflect.Type, in []*inType)
328327
n.output = &outType{typ: outTyp}
329328
x.providers[n.output.typ] = append(x.providers[n.output.typ], n)
330329
case reflect.Struct:
331-
log.Debug().Str("name", outTyp.Name()).Msg("struct info")
330+
logger.Debug().Str("name", outTyp.Name()).Msg("struct info")
332331
for i := 0; i < outTyp.NumField(); i++ {
333332
x.handleProvide(fnVal, outTyp.Field(i).Type, in)
334333
}
@@ -419,6 +418,6 @@ func (x *Dix) provide(param interface{}) {
419418

420419
dep, ok := x.isCycle()
421420
if ok {
422-
log.Fatal().Str("cycle", dep).Msg("provider circular dependency")
421+
logger.Fatal().Str("cycle", dep).Msg("provider circular dependency")
423422
}
424423
}

0 commit comments

Comments
 (0)