-
Notifications
You must be signed in to change notification settings - Fork 0
/
log.go
202 lines (170 loc) · 5.82 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
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
191
192
193
194
195
196
197
198
199
200
201
202
// Code generated by go generate; DO NOT EDIT.
// This file was generated by gen/main.go at 2022-09-20 16:00:00.129406 +0200 CEST m=+0.001519376
package chainsaw
import (
"fmt"
"strings"
)
func join(vals []interface{}) string {
ss := make([]string, len(vals))
for i, value := range vals {
ss[i] = fmt.Sprint(value)
}
return strings.Join(ss, " ")
}
// Trace takes a number of arguments, makes them into strings and logs
// them with level TraceLevel
func (l *CircularLogger) Trace(v ...interface{}) {
s := join(v)
l.log(TraceLevel, s, "")
}
// Tracef takes a format and arguments, formats a string a logs it with TraceLevel
func (l *CircularLogger) Tracef(f string, v ...interface{}) {
s := fmt.Sprintf(f, v...)
l.log(TraceLevel, s, "")
}
// Tracew takes a message and a number of pairs, type chainsaw.P. A fully structured
// log message will be generated with the pairs formatted into key/value pairs
// Note that keys must be strings, values can be strings, numbers, time.Time and a few other types.
func (l *CircularLogger) Tracew(msg string, pairs ...P) {
fields := l.formatFields(pairs)
l.log(TraceLevel, msg, fields)
}
func Trace(v ...interface{}) {
l := defaultLogger
l.Trace(v...)
}
func Tracef(f string, v ...interface{}) {
l := defaultLogger
l.Tracef(f, v...)
}
// Debug takes a number of arguments, makes them into strings and logs
// them with level DebugLevel
func (l *CircularLogger) Debug(v ...interface{}) {
s := join(v)
l.log(DebugLevel, s, "")
}
// Debugf takes a format and arguments, formats a string a logs it with DebugLevel
func (l *CircularLogger) Debugf(f string, v ...interface{}) {
s := fmt.Sprintf(f, v...)
l.log(DebugLevel, s, "")
}
// Debugw takes a message and a number of pairs, type chainsaw.P. A fully structured
// log message will be generated with the pairs formatted into key/value pairs
// Note that keys must be strings, values can be strings, numbers, time.Time and a few other types.
func (l *CircularLogger) Debugw(msg string, pairs ...P) {
fields := l.formatFields(pairs)
l.log(DebugLevel, msg, fields)
}
func Debug(v ...interface{}) {
l := defaultLogger
l.Debug(v...)
}
func Debugf(f string, v ...interface{}) {
l := defaultLogger
l.Debugf(f, v...)
}
// Info takes a number of arguments, makes them into strings and logs
// them with level InfoLevel
func (l *CircularLogger) Info(v ...interface{}) {
s := join(v)
l.log(InfoLevel, s, "")
}
// Infof takes a format and arguments, formats a string a logs it with InfoLevel
func (l *CircularLogger) Infof(f string, v ...interface{}) {
s := fmt.Sprintf(f, v...)
l.log(InfoLevel, s, "")
}
// Infow takes a message and a number of pairs, type chainsaw.P. A fully structured
// log message will be generated with the pairs formatted into key/value pairs
// Note that keys must be strings, values can be strings, numbers, time.Time and a few other types.
func (l *CircularLogger) Infow(msg string, pairs ...P) {
fields := l.formatFields(pairs)
l.log(InfoLevel, msg, fields)
}
func Info(v ...interface{}) {
l := defaultLogger
l.Info(v...)
}
func Infof(f string, v ...interface{}) {
l := defaultLogger
l.Infof(f, v...)
}
// Warn takes a number of arguments, makes them into strings and logs
// them with level WarnLevel
func (l *CircularLogger) Warn(v ...interface{}) {
s := join(v)
l.log(WarnLevel, s, "")
}
// Warnf takes a format and arguments, formats a string a logs it with WarnLevel
func (l *CircularLogger) Warnf(f string, v ...interface{}) {
s := fmt.Sprintf(f, v...)
l.log(WarnLevel, s, "")
}
// Warnw takes a message and a number of pairs, type chainsaw.P. A fully structured
// log message will be generated with the pairs formatted into key/value pairs
// Note that keys must be strings, values can be strings, numbers, time.Time and a few other types.
func (l *CircularLogger) Warnw(msg string, pairs ...P) {
fields := l.formatFields(pairs)
l.log(WarnLevel, msg, fields)
}
func Warn(v ...interface{}) {
l := defaultLogger
l.Warn(v...)
}
func Warnf(f string, v ...interface{}) {
l := defaultLogger
l.Warnf(f, v...)
}
// Error takes a number of arguments, makes them into strings and logs
// them with level ErrorLevel
func (l *CircularLogger) Error(v ...interface{}) {
s := join(v)
l.log(ErrorLevel, s, "")
}
// Errorf takes a format and arguments, formats a string a logs it with ErrorLevel
func (l *CircularLogger) Errorf(f string, v ...interface{}) {
s := fmt.Sprintf(f, v...)
l.log(ErrorLevel, s, "")
}
// Errorw takes a message and a number of pairs, type chainsaw.P. A fully structured
// log message will be generated with the pairs formatted into key/value pairs
// Note that keys must be strings, values can be strings, numbers, time.Time and a few other types.
func (l *CircularLogger) Errorw(msg string, pairs ...P) {
fields := l.formatFields(pairs)
l.log(ErrorLevel, msg, fields)
}
func Error(v ...interface{}) {
l := defaultLogger
l.Error(v...)
}
func Errorf(f string, v ...interface{}) {
l := defaultLogger
l.Errorf(f, v...)
}
// Fatal takes a number of arguments, makes them into strings and logs
// them with level FatalLevel
func (l *CircularLogger) Fatal(v ...interface{}) {
s := join(v)
l.log(FatalLevel, s, "")
}
// Fatalf takes a format and arguments, formats a string a logs it with FatalLevel
func (l *CircularLogger) Fatalf(f string, v ...interface{}) {
s := fmt.Sprintf(f, v...)
l.log(FatalLevel, s, "")
}
// Fatalw takes a message and a number of pairs, type chainsaw.P. A fully structured
// log message will be generated with the pairs formatted into key/value pairs
// Note that keys must be strings, values can be strings, numbers, time.Time and a few other types.
func (l *CircularLogger) Fatalw(msg string, pairs ...P) {
fields := l.formatFields(pairs)
l.log(FatalLevel, msg, fields)
}
func Fatal(v ...interface{}) {
l := defaultLogger
l.Fatal(v...)
}
func Fatalf(f string, v ...interface{}) {
l := defaultLogger
l.Fatalf(f, v...)
}