-
Notifications
You must be signed in to change notification settings - Fork 2.4k
/
zaplogger.go
80 lines (63 loc) · 1.94 KB
/
zaplogger.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
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
package datadogexporter // import "github.com/open-telemetry/opentelemetry-collector-contrib/exporter/datadogexporter"
import (
"fmt"
"go.uber.org/zap"
)
// zaplogger implements the tracelog.Logger interface on top of a zap.Logger
type zaplogger struct{ logger *zap.Logger }
// Trace implements Logger.
func (z *zaplogger) Trace(_ ...any) { /* N/A */ }
// Tracef implements Logger.
func (z *zaplogger) Tracef(_ string, _ ...any) { /* N/A */ }
// Debug implements Logger.
func (z *zaplogger) Debug(v ...any) {
z.logger.Debug(fmt.Sprint(v...))
}
// Debugf implements Logger.
func (z *zaplogger) Debugf(format string, params ...any) {
z.logger.Debug(fmt.Sprintf(format, params...))
}
// Info implements Logger.
func (z *zaplogger) Info(v ...any) {
z.logger.Info(fmt.Sprint(v...))
}
// Infof implements Logger.
func (z *zaplogger) Infof(format string, params ...any) {
z.logger.Info(fmt.Sprintf(format, params...))
}
// Warn implements Logger.
func (z *zaplogger) Warn(v ...any) error {
z.logger.Warn(fmt.Sprint(v...))
return nil
}
// Warnf implements Logger.
func (z *zaplogger) Warnf(format string, params ...any) error {
z.logger.Warn(fmt.Sprintf(format, params...))
return nil
}
// Error implements Logger.
func (z *zaplogger) Error(v ...any) error {
z.logger.Error(fmt.Sprint(v...))
return nil
}
// Errorf implements Logger.
func (z *zaplogger) Errorf(format string, params ...any) error {
z.logger.Error(fmt.Sprintf(format, params...))
return nil
}
// Critical implements Logger.
func (z *zaplogger) Critical(v ...any) error {
z.logger.Error(fmt.Sprint(v...), zap.Bool("critical", true))
return nil
}
// Criticalf implements Logger.
func (z *zaplogger) Criticalf(format string, params ...any) error {
z.logger.Error(fmt.Sprintf(format, params...), zap.Bool("critical", true))
return nil
}
// Flush implements Logger.
func (z *zaplogger) Flush() {
_ = z.logger.Sync()
}