-
Notifications
You must be signed in to change notification settings - Fork 4.6k
/
log.go
64 lines (49 loc) · 1.48 KB
/
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
package utils
// LogLevel of quic-go
type LogLevel uint8
const (
// LogLevelNothing disables
LogLevelNothing LogLevel = iota
// LogLevelError enables err logs
LogLevelError
// LogLevelInfo enables info logs (e.g. packets)
LogLevelInfo
// LogLevelDebug enables debug logs (e.g. packet contents)
LogLevelDebug
)
// A Logger logs.
type Logger interface {
SetLogLevel(LogLevel)
SetLogTimeFormat(format string)
WithPrefix(prefix string) Logger
Debug() bool
Errorf(format string, args ...interface{})
Infof(format string, args ...interface{})
Debugf(format string, args ...interface{})
}
// DefaultLogger is used by quic-go for logging.
var DefaultLogger Logger
type defaultLogger struct{}
var _ Logger = &defaultLogger{}
// SetLogLevel sets the log level
func (l *defaultLogger) SetLogLevel(level LogLevel) {
}
// SetLogTimeFormat sets the format of the timestamp
// an empty string disables the logging of timestamps
func (l *defaultLogger) SetLogTimeFormat(format string) {}
// Debugf logs something
func (l *defaultLogger) Debugf(format string, args ...interface{}) {}
// Infof logs something
func (l *defaultLogger) Infof(format string, args ...interface{}) {}
// Errorf logs something
func (l *defaultLogger) Errorf(format string, args ...interface{}) {}
func (l *defaultLogger) WithPrefix(prefix string) Logger {
return l
}
// Debug returns true if the log level is LogLevelDebug
func (l *defaultLogger) Debug() bool {
return false
}
func init() {
DefaultLogger = &defaultLogger{}
}