wp-go/internal/pkg/logs/log.go
2023-01-13 14:04:32 +08:00

27 lines
420 B
Go

package logs
import (
"log"
"strings"
)
func ErrPrintln(err error, desc string, args ...any) {
s := strings.Builder{}
tmp := "%s err:[%s]"
if desc == "" {
tmp = "%s%s"
}
s.WriteString(tmp)
argss := []any{desc, err}
if len(args) > 0 {
s.WriteString(" args:")
for _, arg := range args {
s.WriteString("%v ")
argss = append(argss, arg)
}
}
if err != nil {
log.Printf(s.String(), argss...)
}
}