/
adapter.go
48 lines (39 loc) · 1.18 KB
/
adapter.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
// Copyright 2015 Keybase, Inc. All rights reserved. Use of
// this source code is governed by the included BSD license.
package logger
// Loggerf is a minimal log interface (using proper formatter style methods)
type Loggerf interface {
Debugf(s string, args ...interface{})
Infof(s string, args ...interface{})
Warningf(s string, args ...interface{})
Errorf(s string, args ...interface{})
}
type loggerInternal interface {
Debug(s string, args ...interface{})
Info(s string, args ...interface{})
Warning(s string, args ...interface{})
Errorf(s string, args ...interface{})
}
type logf struct {
log loggerInternal
}
// NewLoggerf adapts a logger
func NewLoggerf(log loggerInternal) Loggerf {
return logf{log: log}
}
// Debugf forwards to Logger.Debug
func (l logf) Debugf(s string, args ...interface{}) {
l.log.Debug(s, args...)
}
// Infof forwards to Logger.Info
func (l logf) Infof(s string, args ...interface{}) {
l.log.Info(s, args...)
}
// Warningf forwards to Logger.Warning
func (l logf) Warningf(s string, args ...interface{}) {
l.log.Warning(s, args...)
}
// Errorf forwards to Logger.Errorf
func (l logf) Errorf(s string, args ...interface{}) {
l.log.Errorf(s, args...)
}