-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathklog.go
41 lines (32 loc) · 924 Bytes
/
klog.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package logger
import (
"fmt"
"k8s.io/klog/v2"
)
func NewKlog(prefix string) *klogLogger {
if prefix != "" {
prefix += ": "
}
return &klogLogger{prefix: prefix}
}
type klogLogger struct {
prefix string
}
func (l *klogLogger) Error(args ...interface{}) {
klog.ErrorDepth(1, l.prefix, fmt.Sprintln(args...))
}
func (l *klogLogger) Errorf(format string, args ...interface{}) {
klog.ErrorDepth(1, l.prefix, fmt.Sprintf(format, args...))
}
func (l *klogLogger) Warning(args ...interface{}) {
klog.WarningDepth(1, l.prefix, fmt.Sprintln(args...))
}
func (l *klogLogger) Warningf(format string, args ...interface{}) {
klog.WarningDepth(1, l.prefix, fmt.Sprintf(format, args...))
}
func (l *klogLogger) Info(args ...interface{}) {
klog.InfoDepth(1, l.prefix, fmt.Sprintln(args...))
}
func (l *klogLogger) Infof(format string, args ...interface{}) {
klog.InfoDepth(1, l.prefix, fmt.Sprintf(format, args...))
}