-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstd.go
More file actions
190 lines (153 loc) · 5.91 KB
/
std.go
File metadata and controls
190 lines (153 loc) · 5.91 KB
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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
package mo
import (
"context"
"os"
)
// std is the default Logger instance used by the package-level logging functions.
var std = New(context.Background(), NewLogger(DefaultRecorder))
// With returns a new Helper instance with the specified context.
func With(ctx context.Context) *Helper {
return std.With(ctx)
}
// Enabled returns whether logging at the specified level is enabled for the default logger.
func Enabled(level Level) bool {
return std.Logger.Enabled(level)
}
// SetRecorder sets the recorder for the default logger.
func SetRecorder(out Recorder) {
std.Logger.SetRecorder(out)
}
// SetLevel sets the log level for the default logger.
func SetLevel(level Level) {
std.Logger.SetLevel(level)
}
// SetBase sets the base key-value pairs for the default logger.
func SetBase(kv ...Field) {
std.Logger.SetBase(kv...)
}
// Debug logs a message at the debug level.
func Debug(a ...interface{}) {
std.Logger.Print(std.ctx, LevelDebug, a...)
}
// Debugf logs a formatted message at the debug level.
func Debugf(format string, a ...interface{}) {
std.Logger.Printf(std.ctx, LevelDebug, format, a...)
}
// Debugw logs a message with key-value pairs at the debug level.
func Debugw(msg string, kv ...Field) {
std.Logger.Printw(std.ctx, LevelDebug, msg, kv...)
}
// Debugx logs a message at the debug level with the given context.
func Debugx(ctx context.Context, a ...interface{}) {
std.Logger.Print(ctx, LevelDebug, a...)
}
// Debugfx logs a formatted message at the debug level with the given context.
func Debugfx(ctx context.Context, format string, a ...interface{}) {
std.Logger.Printf(ctx, LevelDebug, format, a...)
}
// Debugwx logs a message with key-value pairs at the debug level with the given context.
func Debugwx(ctx context.Context, msg string, kv ...Field) {
std.Logger.Printw(ctx, LevelDebug, msg, kv...)
}
// Info logs a message at the info level.
func Info(a ...interface{}) {
std.Logger.Print(std.ctx, LevelInfo, a...)
}
// Infof logs a formatted message at the info level.
func Infof(format string, a ...interface{}) {
std.Logger.Printf(std.ctx, LevelInfo, format, a...)
}
// Infow logs a message with key-value pairs at the info level.
func Infow(msg string, kv ...Field) {
std.Logger.Printw(std.ctx, LevelInfo, msg, kv...)
}
// Infox logs a message at the info level with the given context.
func Infox(ctx context.Context, a ...interface{}) {
std.Logger.Print(ctx, LevelInfo, a...)
}
// Infofx logs a formatted message at the info level with the given context.
func Infofx(ctx context.Context, format string, a ...interface{}) {
std.Logger.Printf(ctx, LevelInfo, format, a...)
}
// Infowx logs a message with key-value pairs at the info level with the given context.
func Infowx(ctx context.Context, msg string, kv ...Field) {
std.Logger.Printw(ctx, LevelInfo, msg, kv...)
}
// Warn logs a message at the warn level.
func Warn(a ...interface{}) {
std.Logger.Print(std.ctx, LevelWarn, a...)
}
// Warnf logs a formatted message at the warn level.
func Warnf(format string, a ...interface{}) {
std.Logger.Printf(std.ctx, LevelWarn, format, a...)
}
// Warnw logs a message with key-value pairs at the warn level.
func Warnw(msg string, kv ...Field) {
std.Logger.Printw(std.ctx, LevelWarn, msg, kv...)
}
// Warnx logs a message at the warn level with the given context.
func Warnx(ctx context.Context, a ...interface{}) {
std.Logger.Print(ctx, LevelWarn, a...)
}
// Warnfx logs a formatted message at the warn level with the given context.
func Warnfx(ctx context.Context, format string, a ...interface{}) {
std.Logger.Printf(ctx, LevelWarn, format, a...)
}
// Warnwx logs a message with key-value pairs at the warn level with the given context.
func Warnwx(ctx context.Context, msg string, kv ...Field) {
std.Logger.Printw(ctx, LevelWarn, msg, kv...)
}
// Error logs a message at the error level.
func Error(a ...interface{}) {
std.Logger.Print(std.ctx, LevelError, a...)
}
// Errorf logs a formatted message at the error level.
func Errorf(format string, a ...interface{}) {
std.Logger.Printf(std.ctx, LevelError, format, a...)
}
// Errorw logs a message with key-value pairs at the error level.
func Errorw(msg string, kv ...Field) {
std.Logger.Printw(std.ctx, LevelError, msg, kv...)
}
// Errorx logs a message at the error level with the given context.
func Errorx(ctx context.Context, a ...interface{}) {
std.Logger.Print(ctx, LevelError, a...)
}
// Errorfx logs a formatted message at the error level with the given context.
func Errorfx(ctx context.Context, format string, a ...interface{}) {
std.Logger.Printf(ctx, LevelError, format, a...)
}
// Errorwx logs a message with key-value pairs at the error level with the given context.
func Errorwx(ctx context.Context, msg string, kv ...Field) {
std.Logger.Printw(ctx, LevelError, msg, kv...)
}
// Fatal logs a message at the fatal level and exits the program.
func Fatal(a ...interface{}) {
std.Logger.Print(std.ctx, LevelFatal, a...)
os.Exit(1)
}
// Fatalf logs a formatted message at the fatal level and exits the program.
func Fatalf(format string, a ...interface{}) {
std.Logger.Printf(std.ctx, LevelFatal, format, a...)
os.Exit(1)
}
// Fatalw logs a message with key-value pairs at the fatal level and exits the program.
func Fatalw(msg string, kv ...Field) {
std.Logger.Printw(std.ctx, LevelFatal, msg, kv...)
os.Exit(1)
}
// Fatalx logs a message at the fatal level with the given context and exits the program.
func Fatalx(ctx context.Context, a ...interface{}) {
std.Logger.Print(ctx, LevelFatal, a...)
os.Exit(1)
}
// Fatalfx logs a formatted message at the fatal level with the given context and exits the program.
func Fatalfx(ctx context.Context, format string, a ...interface{}) {
std.Logger.Printf(ctx, LevelFatal, format, a...)
os.Exit(1)
}
// Fatalwx logs a message with key-value pairs at the fatal level with the given context and exits the program.
func Fatalwx(ctx context.Context, msg string, kv ...Field) {
std.Logger.Printw(ctx, LevelFatal, msg, kv...)
os.Exit(1)
}