This repository has been archived by the owner on Dec 31, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
dummy.go
67 lines (55 loc) · 2.17 KB
/
dummy.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
// Copyright © 2020 Hedzr Yeh.
package log
import (
"fmt"
"io"
"os"
)
// NewDummyLogger return a dummy logger
func NewDummyLogger() Logger {
return &dummyLogger{}
}
// NewDummyLoggerWithConfig return a dummy logger
func NewDummyLoggerWithConfig(config *LoggerConfig) Logger {
return &dummyLogger{}
}
type dummyLogger struct{}
func (d *dummyLogger) With(key string, val interface{}) Logger { return d }
func (d *dummyLogger) WithFields(fields map[string]interface{}) Logger { return d }
func (d *dummyLogger) Trace(args ...interface{}) {}
func (d *dummyLogger) Debug(args ...interface{}) {}
func (d *dummyLogger) Info(args ...interface{}) {}
func (d *dummyLogger) Warn(args ...interface{}) {}
func (d *dummyLogger) Error(args ...interface{}) {}
func (d *dummyLogger) Fatal(args ...interface{}) {
if InTesting() {
panic(fmt.Sprint(args...))
}
os.Exit(1)
}
func (d *dummyLogger) Panic(args ...interface{}) { panic(fmt.Sprint(args...)) }
func (d *dummyLogger) Print(args ...interface{}) {}
func (d *dummyLogger) Println(args ...interface{}) {}
func (d *dummyLogger) Tracef(msg string, args ...interface{}) {}
func (d *dummyLogger) Debugf(msg string, args ...interface{}) {}
func (d *dummyLogger) Infof(msg string, args ...interface{}) {}
func (d *dummyLogger) Warnf(msg string, args ...interface{}) {}
func (d *dummyLogger) Errorf(msg string, args ...interface{}) {}
func (d *dummyLogger) Fatalf(msg string, args ...interface{}) {
// panic("implement me")
if InTesting() {
panic(fmt.Sprintf(msg, args...))
}
os.Exit(1)
}
func (d *dummyLogger) Panicf(msg string, args ...interface{}) { panic(fmt.Sprintf(msg, args...)) }
func (d *dummyLogger) Printf(msg string, args ...interface{}) {}
func (d *dummyLogger) SetLevel(lvl Level) {}
func (d *dummyLogger) GetLevel() Level { return InfoLevel }
func (d *dummyLogger) SetOutput(out io.Writer) {}
func (d *dummyLogger) GetOutput() (out io.Writer) { return (&stdLogger{}).GetOutput() }
func (d *dummyLogger) Setup() {}
func (d *dummyLogger) AddSkip(skip int) Logger { return d }
//
//
//