Skip to content

Commit

Permalink
fixed: step sorted and debug print
Browse files Browse the repository at this point in the history
  • Loading branch information
alonelucky committed Feb 7, 2024
1 parent 115c95e commit b806354
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
10 changes: 5 additions & 5 deletions injects/global.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ type global struct {
}

func (s *global) SetFullpath(t bool) {
s.g.fullpath = true
s.g.fullpath = t
}

func (s *global) SetDebug(t bool) {
s.g.debug = true
s.g.debug = t
}

func (s *global) Register(v interface{}, cfgs ...*Config) {
Expand Down Expand Up @@ -72,12 +72,12 @@ func (s *global) Action() (e error) {
return s.data[i].S < s.data[j].S
})
var arr []string
var by Step = 255
var by int16 = -1
for idx := range s.data {
if by != s.data[idx].S {
if s := int16(s.data[idx].S); by != s {
sb.WriteString(fmt.Sprintf(" [step %d]: %v\n", by, arr))
arr = []string{}
by = s.data[idx].S
by = s
}
arr = append(arr, s.data[idx].o.String())
if v, ok := s.data[idx].o.Value.(interface{ Register() (e error) }); ok {
Expand Down
12 changes: 6 additions & 6 deletions injects/inject.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ func (g *Graph) Provide(objects ...*Object) error {
g.named[o.Name] = o
}

if g.logger != nil {
if g.logger != nil && g.debug {
if o.created {
g.logger.Debugf("created %s", o)
} else if o.embedded {
Expand Down Expand Up @@ -307,7 +307,7 @@ StructLoop:
}

field.Set(reflect.ValueOf(existing.Value))
if g.logger != nil {
if g.logger != nil && g.debug {
g.logger.Debugf(
"assigned %s to field %s in %s",
existing,
Expand Down Expand Up @@ -365,7 +365,7 @@ StructLoop:
}

field.Set(reflect.MakeMap(fieldType))
if g.logger != nil {
if g.logger != nil && g.debug {
g.logger.Debugf(
"made map for field %s in %s",
o.reflectType.Elem().Field(i).Name,
Expand Down Expand Up @@ -393,7 +393,7 @@ StructLoop:
}
if existing.reflectType.AssignableTo(fieldType) {
field.Set(reflect.ValueOf(existing.Value))
if g.logger != nil {
if g.logger != nil && g.debug {
g.logger.Debugf(
"assigned existing %s to field %s in %s",
existing,
Expand Down Expand Up @@ -422,7 +422,7 @@ StructLoop:

// Finally assign the newly created object to our field.
field.Set(newValue)
if g.logger != nil {
if g.logger != nil && g.debug {
g.logger.Debugf(
"assigned newly created %s to field %s in %s",
newObject,
Expand Down Expand Up @@ -508,7 +508,7 @@ func (g *Graph) populateUnnamedInterface(o *Object) error {
}
found = existing
field.Set(reflect.ValueOf(existing.Value))
if g.logger != nil {
if g.logger != nil && g.debug {
g.logger.Debugf(
"assigned existing %s to interface field %s in %s",
existing,
Expand Down

0 comments on commit b806354

Please sign in to comment.