forked from mongodb/grip
-
Notifications
You must be signed in to change notification settings - Fork 0
/
interface.go
126 lines (109 loc) · 3.74 KB
/
interface.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
package grip
import (
"github.com/mongodb/grip/level"
"github.com/mongodb/grip/send"
)
// Journaler describes the public interface of the the Grip
// interface. Used to enforce consistency between the grip and logging
// packages.
type Journaler interface {
Name() string
SetName(string)
// Methods to access the underlying message sending backend.
GetSender() send.Sender
SetSender(send.Sender) error
// Configure the default and threshold levels of the current
// sender.
SetThreshold(interface{})
ThresholdLevel() level.Priority
SetDefaultLevel(interface{})
DefaultLevel() level.Priority
// Specify a log level as an argument rather than a method
// name.
Log(level.Priority, interface{})
Logf(level.Priority, string, ...interface{})
Logln(level.Priority, ...interface{})
LogWhen(bool, level.Priority, interface{})
LogWhenf(bool, level.Priority, string, ...interface{})
LogWhenln(bool, level.Priority, ...interface{})
// Log a message (the contents of the error,) only if the
// error is non-nil. These are redundant to the similar base
// methods. (e.g. Alert and CatchAlert have the same behavior.)
CatchLog(level.Priority, error)
CatchEmergency(error)
CatchAlert(error)
CatchCritical(error)
CatchError(error)
CatchWarning(error)
CatchNotice(error)
CatchInfo(error)
CatchDebug(error)
// Methods for sending messages at specific levels. If you
// send a message at a level that is below the threshold, then it is a no-op.
// Emergency methods have "panic" and "fatal" variants that
// call panic or os.Exit(1). It is impossible for "Emergency"
// to be below threshold, however, if the message isn't
// loggable (e.g. error is nil, or message is empty,) these
// methods will not panic/error.
CatchEmergencyFatal(error)
CatchEmergencyPanic(error)
EmergencyFatal(interface{})
EmergencyFatalf(string, ...interface{})
EmergencyFatalln(...interface{})
EmergencyPanic(interface{})
EmergencyPanicf(string, ...interface{})
EmergencyPanicln(...interface{})
// For each level, in addition to a basic logger that takes
// strings and message.Composer objects (and tries to do its best
// with everythingelse.) there are println and printf
// loggers. Each Level also has "When" variants that only log
// if the passed condition are true.
Emergency(interface{})
Emergencyf(string, ...interface{})
Emergencyln(...interface{})
EmergencyWhen(bool, interface{})
EmergencyWhenf(bool, string, ...interface{})
EmergencyWhenln(bool, ...interface{})
Alert(interface{})
Alertf(string, ...interface{})
Alertln(...interface{})
AlertWhen(bool, interface{})
AlertWhenf(bool, string, ...interface{})
AlertWhenln(bool, ...interface{})
Critical(interface{})
Criticalf(string, ...interface{})
Criticalln(...interface{})
CriticalWhen(bool, interface{})
CriticalWhenf(bool, string, ...interface{})
CriticalWhenln(bool, ...interface{})
Error(interface{})
Errorf(string, ...interface{})
Errorln(...interface{})
ErrorWhen(bool, interface{})
ErrorWhenf(bool, string, ...interface{})
ErrorWhenln(bool, ...interface{})
Warning(interface{})
Warningf(string, ...interface{})
Warningln(...interface{})
WarningWhen(bool, interface{})
WarningWhenf(bool, string, ...interface{})
WarningWhenln(bool, ...interface{})
Notice(interface{})
Noticef(string, ...interface{})
Noticeln(...interface{})
NoticeWhen(bool, interface{})
NoticeWhenf(bool, string, ...interface{})
NoticeWhenln(bool, ...interface{})
Info(interface{})
Infof(string, ...interface{})
Infoln(...interface{})
InfoWhen(bool, interface{})
InfoWhenf(bool, string, ...interface{})
InfoWhenln(bool, ...interface{})
Debug(interface{})
Debugf(string, ...interface{})
Debugln(...interface{})
DebugWhen(bool, interface{})
DebugWhenf(bool, string, ...interface{})
DebugWhenln(bool, ...interface{})
}