-
Notifications
You must be signed in to change notification settings - Fork 95
/
logger.go
40 lines (31 loc) · 919 Bytes
/
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
package kv
import (
"fmt"
"github.com/dgraph-io/badger/v4"
"go.uber.org/zap"
"github.com/bloxapp/ssv/logging"
)
// badgerLogger is a wrapper for badger.Logger
type badgerLogger struct {
logger *zap.Logger
}
// newLogger creates a new instance of logger
func newLogger(l *zap.Logger) badger.Logger {
return &badgerLogger{l.Named(logging.NameBadgerDBLog)}
}
// Errorf implements badger.Logger
func (bl *badgerLogger) Errorf(s string, i ...interface{}) {
bl.logger.Error(fmt.Sprintf(s, i...))
}
// Warningf implements badger.Logger
func (bl *badgerLogger) Warningf(s string, i ...interface{}) {
bl.logger.Warn(fmt.Sprintf(s, i...))
}
// Infof implements badger.Logger
func (bl *badgerLogger) Infof(s string, i ...interface{}) {
bl.logger.Info(fmt.Sprintf(s, i...))
}
// Debugf implements badger.Logger
func (bl *badgerLogger) Debugf(s string, i ...interface{}) {
bl.logger.Debug(fmt.Sprintf(s, i...))
}