-
Notifications
You must be signed in to change notification settings - Fork 0
/
noop.go
70 lines (56 loc) · 2.49 KB
/
noop.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
package log
import (
"io"
"time"
)
func init() {
Register("noop", func(_ *Config, _ ...Option) (Logger, error) {
return Noop(), nil
})
}
//Noop returns an implementation of Logger that does nothing when its methods are called.
//This can also be retrieved using "noop" with "Open", though in that case any configuration is ignored.
func Noop() Logger {
return noopL{}
}
////log impl
type noopL struct{}
func (noopL) WithError(_ error) Entry { return noopE{} }
func (noopL) WithField(_ string, _ interface{}) Entry { return noopE{} }
func (noopL) WithFields(_ map[string]interface{}) Entry { return noopE{} }
func (noopL) Entry(_ Level) Entry { return noopE{} }
func (noopL) Trace() Entry { return noopE{} }
func (noopL) Debug() Entry { return noopE{} }
func (noopL) Info() Entry { return noopE{} }
func (noopL) Warn() Entry { return noopE{} }
func (noopL) Error() Entry { return noopE{} }
func (noopL) Panic() Entry { return noopE{} }
func (noopL) Fatal() Entry { return noopE{} }
func (np noopL) WriteCloser(_ Level) io.WriteCloser { return np }
func (noopL) Write(p []byte) (int, error) { return len(p), nil }
func (noopL) Close() error { return nil }
////
////entry impl
type noopE struct{}
func (np noopE) Async() Entry { return np }
func (np noopE) Caller(_ ...int) Entry { return np }
func (np noopE) WithError(_ ...error) Entry { return np }
func (np noopE) WithField(_ string, _ interface{}) Entry { return np }
func (np noopE) WithFields(_ map[string]interface{}) Entry { return np }
func (np noopE) WithBool(_ string, _ ...bool) Entry { return np }
func (np noopE) WithDur(_ string, _ ...time.Duration) Entry { return np }
func (np noopE) WithInt(_ string, _ ...int) Entry { return np }
func (np noopE) WithUint(_ string, _ ...uint) Entry { return np }
func (np noopE) WithStr(_ string, _ ...string) Entry { return np }
func (np noopE) WithTime(_ string, _ ...time.Time) Entry { return np }
func (np noopE) Trace() Entry { return np }
func (np noopE) Debug() Entry { return np }
func (np noopE) Info() Entry { return np }
func (np noopE) Warn() Entry { return np }
func (np noopE) Error() Entry { return np }
func (np noopE) Panic() Entry { return np }
func (np noopE) Fatal() Entry { return np }
func (noopE) Msgf(_ string, _ ...interface{}) {}
func (noopE) Msg(_ string) {}
func (noopE) Send() {}
////