This repository has been archived by the owner on Oct 28, 2020. It is now read-only.
/
log.go
64 lines (53 loc) · 1.7 KB
/
log.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package log
import (
"flag"
"io"
"github.com/kiyonlin/klog"
)
// InitFlags is for explicitly initializing the flags.
// Default to use logs as log dir.
func InitFlags(flagset *flag.FlagSet) {
klog.InitFlags(flagset)
}
// SetOutput sets the output destination for all severities
func SetOutput(w io.Writer) {
klog.SetOutput(w)
}
// Flush flushes all pending log I/O.
func Flush() {
klog.Flush()
}
// Warningln logs to the WARNING and INFO logs.
// Arguments are handled in the manner of fmt.Println; a newline is always appended.
func Warningln(args ...interface{}) {
klog.WarningDepth(1, args...)
}
// Warningf logs to the WARNING and INFO logs.
// Arguments are handled in the manner of fmt.Printf; a newline is appended if missing.
func Warningf(format string, args ...interface{}) {
klog.WarningDepthf(1, format, args...)
}
// Errorln logs to the ERROR, WARNING, and INFO logs.
// Arguments are handled in the manner of fmt.Println; a newline is always appended.
func Errorln(args ...interface{}) {
klog.ErrorDepth(1, args...)
}
// Errorf logs to the ERROR, WARNING, and INFO logs.
// Arguments are handled in the manner of fmt.Printf; a newline is appended if missing.
func Errorf(format string, args ...interface{}) {
klog.ErrorDepthf(1, format, args...)
}
// Infoln is equivalent to the global Infoln function, guarded by the value of v.
func Infoln(level int, args ...interface{}) {
l := klog.Level(level)
if klog.V(l).Enabled() {
klog.V(l).InfoDepth(1, args...)
}
}
// Infof is equivalent to the global Infof function, guarded by the value of v.
func Infof(level int, format string, args ...interface{}) {
l := klog.Level(level)
if klog.V(l).Enabled() {
klog.V(l).InfoDepthf(1, format, args...)
}
}