Fix: Prints should always include new lines (#102795)

* CI: Allow Bench conversion to fail

We shouldn't mark PRs and commits as X if they fail to convert logs with Bench.

* Fix: Prints should always include new lines

* fix: remove unused import
This commit is contained in:
Mariell Hoversholm
2025-03-27 12:27:53 +01:00
committed by GitHub
parent 9094c73e33
commit e1e1d3fd9f
15 changed files with 40 additions and 32 deletions
+17 -8
View File
@@ -2,6 +2,7 @@ package logger
import (
"fmt"
"strings"
)
var (
@@ -10,40 +11,48 @@ var (
func Debug(args ...any) {
if debugmode {
fmt.Print(args...)
fmt.Println(args...)
}
}
func Debugf(fmtString string, args ...any) {
if debugmode {
fmt.Printf(fmtString, args...)
fmt.Printf(addMissingNewline(fmtString), args...)
}
}
func Error(args ...any) {
fmt.Print(args...)
fmt.Println(args...)
}
func Errorf(fmtString string, args ...any) {
fmt.Printf(fmtString, args...)
fmt.Printf(addMissingNewline(fmtString), args...)
}
func Info(args ...any) {
fmt.Print(args...)
fmt.Println(args...)
}
func Infof(fmtString string, args ...any) {
fmt.Printf(fmtString, args...)
fmt.Printf(addMissingNewline(fmtString), args...)
}
func Warn(args ...any) {
fmt.Print(args...)
fmt.Println(args...)
}
func Warnf(fmtString string, args ...any) {
fmt.Printf(fmtString, args...)
fmt.Printf(addMissingNewline(fmtString), args...)
}
func SetDebug(value bool) {
debugmode = value
}
func addMissingNewline(s string) string {
if strings.HasSuffix(s, "\n") {
return s
}
return s + "\n"
}