/
prefix.go
41 lines (32 loc) · 973 Bytes
/
prefix.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
package logx
import "github.com/ooni/probe-engine/pkg/model"
// PrefixLogger is a logger with a prefix.
type PrefixLogger struct {
Prefix string
Logger model.Logger
}
var _ model.Logger = &PrefixLogger{}
// Debug implements DebugLogger.Debug
func (p *PrefixLogger) Debug(msg string) {
p.Logger.Debug(p.Prefix + msg)
}
// Debugf implements DebugLogger.Debugf
func (p *PrefixLogger) Debugf(format string, v ...interface{}) {
p.Logger.Debugf(p.Prefix+format, v...)
}
// Info implements InfoLogger.Info
func (p *PrefixLogger) Info(msg string) {
p.Logger.Info(p.Prefix + msg)
}
// Infov implements InfoLogger.Infov
func (p *PrefixLogger) Infof(format string, v ...interface{}) {
p.Logger.Infof(p.Prefix+format, v...)
}
// Warn implements Logger.Warn
func (p *PrefixLogger) Warn(msg string) {
p.Logger.Warn(p.Prefix + msg)
}
// Warnf implements Logger.Warnf
func (p *PrefixLogger) Warnf(format string, v ...interface{}) {
p.Logger.Warnf(p.Prefix+format, v...)
}