forked from ava-labs/avalanchego
-
Notifications
You must be signed in to change notification settings - Fork 4
/
test_log.go
76 lines (50 loc) · 1.27 KB
/
test_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
// Copyright (C) 2019-2022, Ava Labs, Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package logging
import (
"io"
"go.uber.org/zap"
)
var (
// Discard is a mock WriterCloser that drops all writes and close requests
Discard io.WriteCloser = discard{}
_ Logger = NoLog{}
)
type NoLog struct{}
func (NoLog) Write(b []byte) (int, error) {
return len(b), nil
}
func (NoLog) Fatal(string, ...zap.Field) {}
func (NoLog) Error(string, ...zap.Field) {}
func (NoLog) Warn(string, ...zap.Field) {}
func (NoLog) Info(string, ...zap.Field) {}
func (NoLog) Trace(string, ...zap.Field) {}
func (NoLog) Debug(string, ...zap.Field) {}
func (NoLog) Verbo(string, ...zap.Field) {}
func (NoLog) SetLevel(Level) {}
func (NoLog) StopOnPanic() {}
func (NoLog) RecoverAndPanic(f func()) {
f()
}
func (NoLog) RecoverAndExit(f, exit func()) {
defer exit()
f()
}
func (NoLog) Stop() {}
type NoWarn struct{ NoLog }
func (NoWarn) Fatal(string, ...zap.Field) {
panic("unexpected Fatal")
}
func (NoWarn) Error(string, ...zap.Field) {
panic("unexpected Error")
}
func (NoWarn) Warn(string, ...zap.Field) {
panic("unexpected Warn")
}
type discard struct{}
func (discard) Write(p []byte) (int, error) {
return len(p), nil
}
func (discard) Close() error {
return nil
}