-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathlog.go
44 lines (32 loc) · 999 Bytes
/
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
package openairt
import "log"
type Logger interface {
Debugf(format string, v ...any)
Infof(format string, v ...any)
Warnf(format string, v ...any)
Errorf(format string, v ...any)
}
// NopLogger is a logger that does nothing.
type NopLogger struct{}
// Errorf does nothing.
func (l NopLogger) Errorf(_ string, _ ...any) {}
// Warnf does nothing.
func (l NopLogger) Warnf(_ string, _ ...any) {}
// Infof does nothing.
func (l NopLogger) Infof(_ string, _ ...any) {}
// Debugf does nothing.
func (l NopLogger) Debugf(_ string, _ ...any) {}
// StdLogger is a logger that logs to the "log" package.
type StdLogger struct{}
func (l StdLogger) Errorf(format string, v ...any) {
log.Printf("[ERROR] "+format, v...)
}
func (l StdLogger) Warnf(format string, v ...any) {
log.Printf("[WARN] "+format, v...)
}
func (l StdLogger) Infof(format string, v ...any) {
log.Printf("[INFO] "+format, v...)
}
func (l StdLogger) Debugf(format string, v ...any) {
log.Printf("[DEBUG] "+format, v...)
}