github.com/MetalBlockchain/metalgo@v1.11.9/utils/logging/test_log.go (about) 1 // Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. 2 // See the file LICENSE for licensing terms. 3 4 package logging 5 6 import ( 7 "io" 8 9 "go.uber.org/zap" 10 ) 11 12 var ( 13 // Discard is a mock WriterCloser that drops all writes and close requests 14 Discard io.WriteCloser = discard{} 15 16 _ Logger = NoLog{} 17 ) 18 19 type NoLog struct{} 20 21 func (NoLog) Write(b []byte) (int, error) { 22 return len(b), nil 23 } 24 25 func (NoLog) Fatal(string, ...zap.Field) {} 26 27 func (NoLog) Error(string, ...zap.Field) {} 28 29 func (NoLog) Warn(string, ...zap.Field) {} 30 31 func (NoLog) Info(string, ...zap.Field) {} 32 33 func (NoLog) Trace(string, ...zap.Field) {} 34 35 func (NoLog) Debug(string, ...zap.Field) {} 36 37 func (NoLog) Verbo(string, ...zap.Field) {} 38 39 func (NoLog) SetLevel(Level) {} 40 41 func (NoLog) Enabled(Level) bool { 42 return false 43 } 44 45 func (NoLog) StopOnPanic() {} 46 47 func (NoLog) RecoverAndPanic(f func()) { 48 f() 49 } 50 51 func (NoLog) RecoverAndExit(f, exit func()) { 52 defer exit() 53 f() 54 } 55 56 func (NoLog) Stop() {} 57 58 type NoWarn struct{ NoLog } 59 60 func (NoWarn) Fatal(string, ...zap.Field) { 61 panic("unexpected Fatal") 62 } 63 64 func (NoWarn) Error(string, ...zap.Field) { 65 panic("unexpected Error") 66 } 67 68 func (NoWarn) Warn(string, ...zap.Field) { 69 panic("unexpected Warn") 70 } 71 72 type discard struct{} 73 74 func (discard) Write(p []byte) (int, error) { 75 return len(p), nil 76 } 77 78 func (discard) Close() error { 79 return nil 80 }