-
Notifications
You must be signed in to change notification settings - Fork 4
/
default.go
174 lines (132 loc) · 3.57 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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
package suplog
import (
"context"
"time"
)
var (
// DefaultLogger provides a way to pass default logger into Hook initializers.
//
// nolint:gochecknoglobals
DefaultLogger = &suplogger{}
// Ensure that defaultOpt's type *suplogger matches Logger interface
// during the compilation phase.
_ Logger = DefaultLogger
)
// CLASSIC LOGGER METHODS
// Print will print to the underlying writer.
func Print(str string) {
DefaultLogger.Print(str)
}
// Printf will print a formatted message to the underlying writer.
func Printf(format string, args ...interface{}) {
DefaultLogger.Printf(format, args...)
}
// Notification will log a notification message.
func Notification(format string, args ...interface{}) {
DefaultLogger.Notification(format, args...)
}
// Success will log a success message.
func Success(format string, args ...interface{}) {
DefaultLogger.Success(format, args...)
}
// Warning will log a warning message.
func Warning(format string, args ...interface{}) {
DefaultLogger.Warning(format, args...)
}
// Error will log an error message.
func Error(format string, args ...interface{}) {
DefaultLogger.Error(format, args...)
}
// Debug will log a debug line.
func Debug(format string, args ...interface{}) {
DefaultLogger.Debug(format, args...)
}
// OUTPUTTER METHODS
//
// Part A: Context providers
func WithField(key string, value interface{}) Logger {
return DefaultLogger.WithField(key, value)
}
func WithFields(fields Fields) Logger {
return DefaultLogger.WithFields(fields)
}
func WithError(err error) Logger {
return DefaultLogger.WithError(err)
}
func WithContext(ctx context.Context) Logger {
return DefaultLogger.WithContext(ctx)
}
func WithTime(t time.Time) Logger {
return DefaultLogger.WithTime(t)
}
// Part B: Formatted logging methods
func Logf(level Level, format string, args ...interface{}) {
DefaultLogger.Logf(level, format, args...)
}
func Tracef(format string, args ...interface{}) {
DefaultLogger.Tracef(format, args...)
}
func Debugf(format string, args ...interface{}) {
DefaultLogger.Debugf(format, args...)
}
func Infof(format string, args ...interface{}) {
DefaultLogger.Infof(format, args...)
}
func Warningf(format string, args ...interface{}) {
DefaultLogger.Warningf(format, args...)
}
func Errorf(format string, args ...interface{}) {
DefaultLogger.Errorf(format, args...)
}
func Fatalf(format string, args ...interface{}) {
DefaultLogger.Fatalf(format, args...)
}
func Panicf(format string, args ...interface{}) {
DefaultLogger.Panicf(format, args...)
}
// Part C: Shortcut logging methods
func Log(level Level, args ...interface{}) {
DefaultLogger.Log(level, args...)
}
func Trace(args ...interface{}) {
DefaultLogger.Trace(args...)
}
func Info(args ...interface{}) {
DefaultLogger.Info(args...)
}
func Fatal(args ...interface{}) {
DefaultLogger.Fatal(args...)
}
func Panic(args ...interface{}) {
DefaultLogger.Panic(args...)
}
func Logln(level Level, args ...interface{}) {
DefaultLogger.Logln(level, args...)
}
func Traceln(args ...interface{}) {
DefaultLogger.Traceln(args...)
}
func Debugln(args ...interface{}) {
DefaultLogger.Debugln(args...)
}
func Infoln(args ...interface{}) {
DefaultLogger.Infoln(args...)
}
func Println(args ...interface{}) {
DefaultLogger.Println(args...)
}
func Warningln(args ...interface{}) {
DefaultLogger.Warningln(args...)
}
func Errorln(args ...interface{}) {
DefaultLogger.Errorln(args...)
}
func Fatalln(args ...interface{}) {
DefaultLogger.Fatalln(args...)
}
func Panicln(args ...interface{}) {
DefaultLogger.Panicln(args...)
}
func FnName() string {
return DefaultLogger.CallerName()
}