mirror of
https://github.com/k3s-io/k3s.git
synced 2024-06-07 19:41:36 +00:00
27 lines
644 B
Go
27 lines
644 B
Go
package logging
|
|
|
|
import (
|
|
"fmt"
|
|
"testing"
|
|
)
|
|
|
|
// Func is a function that can be used for logging.
|
|
type Func func(Level, string, ...interface{})
|
|
|
|
// Test returns a logging function that forwards messages to the test logger.
|
|
func Test(t *testing.T) Func {
|
|
return func(l Level, format string, a ...interface{}) {
|
|
format = fmt.Sprintf("%s: %s", l.String(), format)
|
|
t.Logf(format, a...)
|
|
}
|
|
}
|
|
|
|
// Stdout returns a logging function that prints log messages on standard
|
|
// output.
|
|
func Stdout() Func {
|
|
return func(l Level, format string, a ...interface{}) {
|
|
format = fmt.Sprintf("%s: %s\n", l.String(), format)
|
|
fmt.Printf(format, a...)
|
|
}
|
|
}
|