Skip to content

Commit

Permalink
export cfg factories fields (#29)
Browse files Browse the repository at this point in the history
  • Loading branch information
wiggin77 committed Sep 10, 2021
1 parent b544af1 commit 51a79cd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ type TargetFactory func(targetType string, options json.RawMessage) (logr.Target
type FormatterFactory func(format string, options json.RawMessage) (logr.Formatter, error)

type Factories struct {
targetFactory TargetFactory // can be nil
formatterFactory FormatterFactory // can be nil
TargetFactory TargetFactory // can be nil
FormatterFactory FormatterFactory // can be nil
}

var removeAll = func(ti logr.TargetInfo) bool { return true }
Expand All @@ -56,7 +56,7 @@ func ConfigureTargets(lgr *logr.Logr, config map[string]TargetCfg, factories *Fa
}

for name, tcfg := range config {
target, err := newTarget(tcfg.Type, tcfg.Options, factories.targetFactory)
target, err := newTarget(tcfg.Type, tcfg.Options, factories.TargetFactory)
if err != nil {
return fmt.Errorf("error creating log target %s: %w", name, err)
}
Expand All @@ -65,7 +65,7 @@ func ConfigureTargets(lgr *logr.Logr, config map[string]TargetCfg, factories *Fa
continue
}

formatter, err := newFormatter(tcfg.Format, tcfg.FormatOptions, factories.formatterFactory)
formatter, err := newFormatter(tcfg.Format, tcfg.FormatOptions, factories.FormatterFactory)
if err != nil {
return fmt.Errorf("error creating formatter for log target %s: %w", name, err)
}
Expand Down
4 changes: 2 additions & 2 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ func TestConfigureCustomTarget(t *testing.T) {
buf := &test.Buffer{}

factories := Factories{
targetFactory: makeCustomTargetFactory(buf),
formatterFactory: customFormatFactory,
TargetFactory: makeCustomTargetFactory(buf),
FormatterFactory: customFormatFactory,
}

lgr, err := logr.New()
Expand Down

0 comments on commit 51a79cd

Please sign in to comment.