1
0

log.go 779 B

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