Skip to content

Commit

Permalink
Merge pull request #73 from paketo-buildpacks/detect-logging
Browse files Browse the repository at this point in the history
Adds logging to detection
  • Loading branch information
dmikusa authored May 22, 2023
2 parents 1cbc625 + 3047b76 commit 27a1e2c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 3 additions & 2 deletions cmd/main/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ import (
)

func main() {
logger := bard.NewLogger(os.Stdout)
libpak.Main(
elastic.Detect{},
elastic.Build{Logger: bard.NewLogger(os.Stdout)},
elastic.Detect{Logger: logger},
elastic.Build{Logger: logger},
)
}
6 changes: 5 additions & 1 deletion elastic/detect.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,18 @@ import (

"github.com/buildpacks/libcnb"
"github.com/paketo-buildpacks/libpak/bindings"
"github.com/paketo-buildpacks/libpak/bard"
)

type Detect struct{}
type Detect struct{
Logger bard.Logger
}

func (d Detect) Detect(context libcnb.DetectContext) (libcnb.DetectResult, error) {
if _, ok, err := bindings.ResolveOne(context.Platform.Bindings, bindings.OfType("ElasticAPM")); err != nil {
return libcnb.DetectResult{}, fmt.Errorf("unable to resolve binding ElasticAPM\n%w", err)
} else if !ok {
d.Logger.Info("SKIPPED: No binding of type 'ElasticAPM' found")
return libcnb.DetectResult{Pass: false}, nil
}

Expand Down

0 comments on commit 27a1e2c

Please sign in to comment.