Skip to content

Commit

Permalink
Enable log instrumentation via SetLogger (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
radeksimko authored Nov 11, 2021
1 parent e677aa4 commit 38e1640
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
4 changes: 4 additions & 0 deletions installer.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ func NewInstaller() *Installer {
}
}

func (i *Installer) SetLogger(logger *log.Logger) {
i.logger = logger
}

func (i *Installer) Ensure(ctx context.Context, sources []src.Source) (string, error) {
var errs *multierror.Error

Expand Down
8 changes: 7 additions & 1 deletion installer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,18 @@ func TestInstaller_Ensure(t *testing.T) {
// also works and continues working

i := NewInstaller()
_, err := i.Ensure(context.Background(), []src.Source{
i.SetLogger(testutil.TestLogger())
ctx := context.Background()
_, err := i.Ensure(ctx, []src.Source{
&releases.LatestVersion{
Product: product.Terraform,
},
})
if err != nil {
t.Fatal(err)
}
err = i.Remove(ctx)
if err != nil {
t.Fatal(err)
}
}

0 comments on commit 38e1640

Please sign in to comment.