-
Notifications
You must be signed in to change notification settings - Fork 641
/
test_log.go
57 lines (33 loc) · 1.39 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
// Copyright (C) 2019-2021, Ava Labs, Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package logging
import (
"errors"
"io"
)
var (
// Discard is a mock WriterCloser that drops all writes and close requests
Discard io.WriteCloser = discard{}
errNoLoggerWrite = errors.New("NoLogger can't write")
_ Logger = NoLog{}
)
type NoLog struct{}
func (NoLog) Write([]byte) (int, error) { return 0, errNoLoggerWrite }
func (NoLog) Fatal(format string, args ...interface{}) {}
func (NoLog) Error(format string, args ...interface{}) {}
func (NoLog) Warn(format string, args ...interface{}) {}
func (NoLog) Info(format string, args ...interface{}) {}
func (NoLog) Trace(format string, args ...interface{}) {}
func (NoLog) Debug(format string, args ...interface{}) {}
func (NoLog) Verbo(format string, args ...interface{}) {}
func (NoLog) AssertNoError(error) {}
func (NoLog) AssertTrue(b bool, format string, args ...interface{}) {}
func (NoLog) AssertDeferredTrue(f func() bool, format string, args ...interface{}) {}
func (NoLog) AssertDeferredNoError(f func() error) {}
func (NoLog) StopOnPanic() {}
func (NoLog) RecoverAndPanic(f func()) { f() }
func (NoLog) RecoverAndExit(f, exit func()) { defer exit(); f() }
func (NoLog) Stop() {}
type discard struct{}
func (discard) Write(p []byte) (int, error) { return len(p), nil }
func (discard) Close() error { return nil }