Skip to content

Commit

Permalink
Modify framework logging functions to use the By and Fail hooks
Browse files Browse the repository at this point in the history
...which allow the consumer to customize the output.

Signed-off-by: Tom Pantelis <[email protected]>
  • Loading branch information
tpantelis committed Apr 4, 2024
1 parent 2e21d4a commit e6a082d
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions test/e2e/framework/logging.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
"fmt"
"time"

"github.com/onsi/ginkgo/v2"
"github.com/submariner-io/shipyard/test/e2e/framework/ginkgowrapper"
)

Expand All @@ -31,7 +30,7 @@ func nowStamp() string {
}

func log(level, format string, args ...interface{}) {
fmt.Fprintf(ginkgo.GinkgoWriter, nowStamp()+": "+level+": "+format+"\n", args...)
By(fmt.Sprintf(nowStamp()+": "+level+": "+format+"\n", args...))
}

func Errorf(format string, args ...interface{}) {
Expand All @@ -49,9 +48,7 @@ func Failf(format string, args ...interface{}) {
// FailfWithOffset calls "Fail" and logs the error at "offset" levels above its caller
// (for example, for call chain f -> g -> FailfWithOffset(1, ...) error would be logged for "f").
func FailfWithOffset(offset int, format string, args ...interface{}) {
msg := fmt.Sprintf(format, args...)
log("INFO", msg)
ginkgowrapper.Fail(nowStamp()+": "+msg, 1+offset)
Fail(nowStamp()+": "+fmt.Sprintf(format, args...), 1+offset)
}

func Skipf(format string, args ...interface{}) {
Expand Down

0 comments on commit e6a082d

Please sign in to comment.