forked from redpanda-data/connect
-
Notifications
You must be signed in to change notification settings - Fork 0
/
logger.go
99 lines (75 loc) · 2.14 KB
/
logger.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
package pulsar
import (
plog "github.com/apache/pulsar-client-go/pulsar/log"
"github.com/benthosdev/benthos/v4/public/service"
)
// DefaultLogger returns a logger that wraps Benthos Modular logger.
func createDefaultLogger(l *service.Logger) plog.Logger {
return defaultLogger{
backend: l,
}
}
type defaultLogger struct {
backend *service.Logger
}
func (l defaultLogger) SubLogger(fields plog.Fields) plog.Logger {
return l
}
func (l defaultLogger) WithFields(fields plog.Fields) plog.Entry {
return l
}
func (l defaultLogger) WithField(name string, value any) plog.Entry {
return l
}
func (l defaultLogger) WithError(err error) plog.Entry {
return l
}
func (l defaultLogger) Debug(args ...any) {
l.backend.Debugf("%v", args)
}
func (l defaultLogger) Info(args ...any) {
l.backend.Infof("%v", args)
}
func (l defaultLogger) Warn(args ...any) {
l.backend.Warnf("%v", args)
}
func (l defaultLogger) Error(args ...any) {
l.backend.Errorf("%v", args)
}
func (l defaultLogger) Debugf(format string, args ...any) {
l.backend.Debugf(format, args)
}
func (l defaultLogger) Infof(format string, args ...any) {
l.backend.Infof(format, args)
}
func (l defaultLogger) Warnf(format string, args ...any) {
l.backend.Warnf(format, args)
}
func (l defaultLogger) Errorf(format string, args ...any) {
l.backend.Errorf(format, args)
}
// NoopLogger returns a logger that does nothing.
func NoopLogger() plog.Logger {
return noopLogger{}
}
type noopLogger struct{}
func (n noopLogger) SubLogger(fields plog.Fields) plog.Logger {
return n
}
func (n noopLogger) WithFields(fields plog.Fields) plog.Entry {
return n
}
func (n noopLogger) WithField(name string, value any) plog.Entry {
return n
}
func (n noopLogger) WithError(err error) plog.Entry {
return n
}
func (n noopLogger) Debug(args ...any) {}
func (n noopLogger) Info(args ...any) {}
func (n noopLogger) Warn(args ...any) {}
func (n noopLogger) Error(args ...any) {}
func (n noopLogger) Debugf(format string, args ...any) {}
func (n noopLogger) Infof(format string, args ...any) {}
func (n noopLogger) Warnf(format string, args ...any) {}
func (n noopLogger) Errorf(format string, args ...any) {}