| 1 | package framework |
| 2 | |
| 3 | import ( |
| 4 | "fmt" |
| 5 | "time" |
| 6 | |
| 7 | "github.com/onsi/ginkgo/v2" |
| 8 | ) |
| 9 | |
| 10 | func nowStamp() string { |
| 11 | return time.Now().Format(time.StampMilli) |
| 12 | } |
| 13 | |
| 14 | func log(level string, format string, args ...any) { |
| 15 | fmt.Fprintf(ginkgo.GinkgoWriter, nowStamp()+": "+level+": "+format+"\n", args...) |
| 16 | } |
| 17 | |
| 18 | // Logf logs the info. |
| 19 | func Logf(format string, args ...any) { |
| 20 | log("INFO", format, args...) |
| 21 | } |
| 22 | |
| 23 | // Failf logs the fail info, including a stack trace starts with its direct caller |
| 24 | // (for example, for call chain f -> g -> Failf("foo", ...) error would be logged for "g"). |
| 25 | func Failf(format string, args ...any) { |
| 26 | msg := fmt.Sprintf(format, args...) |
| 27 | skip := 1 |
| 28 | ginkgo.Fail(msg, skip) |
| 29 | panic("unreachable") |
| 30 | } |
| 31 | |
| 32 | // Fail is an alias for ginkgo.Fail. |
| 33 | var Fail = ginkgo.Fail |