-
Notifications
You must be signed in to change notification settings - Fork 4
/
default.go
111 lines (88 loc) · 2.72 KB
/
default.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
package log
import "os"
var defaultLogger Logger
func init() {
SetDefaultLogger(NewLogger(os.Stdout, LstdFlags|Lshortfile))
}
// DefaultLogger returns the default logger which writes to os.Stdout.
func DefaultLogger() Logger {
return defaultLogger
}
// SetDefaultLogger sets the default logger with CallerOffset set.
// NOTE: this function is supposed to be called while DefaultLogger is not in use, it's not goroutine safe for performance.
func SetDefaultLogger(logger Logger) {
logger.SetCallerOffset(1)
defaultLogger = logger
}
// Print calls the same method on the default logger.
func Print(a ...interface{}) {
defaultLogger.Print(a...)
}
// Printf calls the same method on the default logger.
func Printf(f string, a ...interface{}) {
defaultLogger.Printf(f, a...)
}
// Println calls the same method on the default logger.
func Println(a ...interface{}) {
defaultLogger.Println(a...)
}
// Debug calls the same method on the default logger.
func Debug(a ...interface{}) {
defaultLogger.Debug(a...)
}
// Debugf calls the same method on the default logger.
func Debugf(f string, a ...interface{}) {
defaultLogger.Debugf(f, a...)
}
// Info calls the same method on the default logger.
func Info(a ...interface{}) {
defaultLogger.Info(a...)
}
// Infof calls the same method on the default logger.
func Infof(f string, a ...interface{}) {
defaultLogger.Infof(f, a...)
}
// Warn calls the same method on the default logger.
func Warn(a ...interface{}) {
defaultLogger.Warn(a...)
}
// Warnf calls the same method on the default logger.
func Warnf(f string, a ...interface{}) {
defaultLogger.Warnf(f, a...)
}
// Error calls the same method on the default logger.
func Error(a ...interface{}) {
defaultLogger.Warn(a...)
}
// Errorf calls the same method on the default logger.
func Errorf(f string, a ...interface{}) {
defaultLogger.Warnf(f, a...)
}
// Fatal calls the same method on the default logger.
func Fatal(a ...interface{}) {
defaultLogger.Fatal(a...)
}
// Fatalf calls the same method on the default logger.
func Fatalf(f string, a ...interface{}) {
defaultLogger.Fatalf(f, a...)
}
// DefaultLevel calls the same method on the default logger.
func DefaultLevel() Level {
return defaultLogger.DefaultLevel()
}
// SetDefaultLevel calls the same method on the default logger.
func SetDefaultLevel(l Level) {
defaultLogger.SetDefaultLevel(l)
}
// OutputLevel calls the same method on the default logger.
func OutputLevel() Level {
return defaultLogger.OutputLevel()
}
// SetOutputLevel calls the same method on the default logger.
func SetOutputLevel(l Level) {
defaultLogger.SetOutputLevel(l)
}
// SetCallerOffset calls the same method on the default logger.
func SetCallerOffset(offset int) {
defaultLogger.SetCallerOffset(offset)
}