From 57e82428c6a1f686d63ac4c0e09d543cd2e618df Mon Sep 17 00:00:00 2001 From: David O'Sullivan Date: Mon, 22 May 2023 14:54:34 +0100 Subject: [PATCH] Adds logging to detection --- cmd/main/main.go | 5 +++-- elastic/detect.go | 6 +++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/cmd/main/main.go b/cmd/main/main.go index 44671b8..a6b0c84 100644 --- a/cmd/main/main.go +++ b/cmd/main/main.go @@ -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}, ) } diff --git a/elastic/detect.go b/elastic/detect.go index 9a19dba..d969f6b 100644 --- a/elastic/detect.go +++ b/elastic/detect.go @@ -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 }