Skip to content

Commit

Permalink
Merge pull request #324 from paketo-buildpacks/detect-logging
Browse files Browse the repository at this point in the history
Adds detection logging messages at info level
  • Loading branch information
anthonydahanne authored May 18, 2023
2 parents 3fb557e + de43045 commit c5fae09
Show file tree
Hide file tree
Showing 2 changed files with 12 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(
stackdriver.Detect{},
stackdriver.Build{Logger: bard.NewLogger(os.Stdout)},
stackdriver.Detect{Logger: logger},
stackdriver.Build{Logger: logger},
)
}
10 changes: 9 additions & 1 deletion stackdriver/detect.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,12 @@ 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) {
result := libcnb.DetectResult{Pass: false}
Expand Down Expand Up @@ -53,6 +56,7 @@ func (d Detect) Detect(context libcnb.DetectContext) (libcnb.DetectResult, error
},
},
)
d.Logger.Info("PASSED: binding of type 'StackdriverDebugger' found")
}

if _, ok, err := bindings.ResolveOne(context.Platform.Bindings, bindings.OfType("StackdriverProfiler")); err != nil {
Expand Down Expand Up @@ -80,7 +84,11 @@ func (d Detect) Detect(context libcnb.DetectContext) (libcnb.DetectResult, error
},
},
)
d.Logger.Info("PASSED: binding of type 'StackdriverProfiler' found")
}

if result.Pass != true {
d.Logger.Info("SKIPPED: no bindings of type 'StackdriverDebugger' or 'StackdriverProfiler' found")
}
return result, nil
}

0 comments on commit c5fae09

Please sign in to comment.