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:
@@ -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"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user