-
Notifications
You must be signed in to change notification settings - Fork 22
/
loggers.go
180 lines (155 loc) · 4.14 KB
/
loggers.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
/*
Basic Logging
Loging helpers exist for the following levels:
Emergency + (fatal/panic)
Alert + (fatal/panic)
Critical + (fatal/panic)
Error + (fatal/panic)
Warning
Notice
Info
Debug
These methods accept both strings (message content,) or types that
implement the message.MessageComposer interface. Composer types make
it possible to delay generating a message unless the logger is over
the logging threshold. Use this to avoid expensive serialization
operations for suppressed logging operations.
All levels also have additional methods with `ln` and `f` appended to
the end of the method name which allow Println() and Printf() style
functionality. You must pass printf/println-style arguments to these methods.
# Conditional Logging
The Conditional logging methods take two arguments, a Boolean, and a
message argument. Messages can be strings, objects that implement the
MessageComposer interface, or errors. If condition boolean is true,
the threshold level is met, and the message to log is not an empty
string, then it logs the resolved message.
Use conditional logging methods to potentially suppress log messages
based on situations orthogonal to log level, with "log sometimes" or
"log rarely" semantics. Combine with MessageComposers to to avoid
expensive message building operations.
*/
package grip
import "github.com/mongodb/grip/level"
func Log(l level.Priority, msg interface{}) {
std.Log(l, msg)
}
func Logf(l level.Priority, msg string, a ...interface{}) {
std.Logf(l, msg, a...)
}
func Logln(l level.Priority, a ...interface{}) {
std.Logln(l, a...)
}
func LogWhen(conditional bool, l level.Priority, m interface{}) {
std.LogWhen(conditional, l, m)
}
// Leveled Logging Methods
// Emergency-level logging methods
func EmergencyFatal(msg interface{}) {
std.EmergencyFatal(msg)
}
func Emergency(msg interface{}) {
std.Emergency(msg)
}
func Emergencyf(msg string, a ...interface{}) {
std.Emergencyf(msg, a...)
}
func Emergencyln(a ...interface{}) {
std.Emergencyln(a...)
}
func EmergencyPanic(msg interface{}) {
std.EmergencyPanic(msg)
}
func EmergencyWhen(conditional bool, m interface{}) {
std.EmergencyWhen(conditional, m)
}
// Alert-level logging methods
func Alert(msg interface{}) {
std.Alert(msg)
}
func Alertf(msg string, a ...interface{}) {
std.Alertf(msg, a...)
}
func Alertln(a ...interface{}) {
std.Alertln(a...)
}
func AlertWhen(conditional bool, m interface{}) {
std.AlertWhen(conditional, m)
}
// Critical-level logging methods
func Critical(msg interface{}) {
std.Critical(msg)
}
func Criticalf(msg string, a ...interface{}) {
std.Criticalf(msg, a...)
}
func Criticalln(a ...interface{}) {
std.Criticalln(a...)
}
func CriticalWhen(conditional bool, m interface{}) {
std.CriticalWhen(conditional, m)
}
// Error-level logging methods
func Error(msg interface{}) {
std.Error(msg)
}
func Errorf(msg string, a ...interface{}) {
std.Errorf(msg, a...)
}
func Errorln(a ...interface{}) {
std.Errorln(a...)
}
func ErrorWhen(conditional bool, m interface{}) {
std.ErrorWhen(conditional, m)
}
// Warning-level logging methods
func Warning(msg interface{}) {
std.Warning(msg)
}
func Warningf(msg string, a ...interface{}) {
std.Warningf(msg, a...)
}
func Warningln(a ...interface{}) {
std.Warningln(a...)
}
func WarningWhen(conditional bool, m interface{}) {
std.WarningWhen(conditional, m)
}
// Notice-level logging methods
func Notice(msg interface{}) {
std.Notice(msg)
}
func Noticef(msg string, a ...interface{}) {
std.Noticef(msg, a...)
}
func Noticeln(a ...interface{}) {
std.Noticeln(a...)
}
func NoticeWhen(conditional bool, m interface{}) {
std.NoticeWhen(conditional, m)
}
// Info-level logging methods
func Info(msg interface{}) {
std.Info(msg)
}
func Infof(msg string, a ...interface{}) {
std.Infof(msg, a...)
}
func Infoln(a ...interface{}) {
std.Infoln(a...)
}
func InfoWhen(conditional bool, message interface{}) {
std.InfoWhen(conditional, message)
}
// Debug-level logging methods
func Debug(msg interface{}) {
std.Debug(msg)
}
func Debugf(msg string, a ...interface{}) {
std.Debugf(msg, a...)
}
func Debugln(a ...interface{}) {
std.Debugln(a...)
}
func DebugWhen(conditional bool, m interface{}) {
std.DebugWhen(conditional, m)
}