forked from pseidemann/finish
-
Notifications
You must be signed in to change notification settings - Fork 0
/
log.go
38 lines (28 loc) · 757 Bytes
/
log.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
package finish
import (
"fmt"
"log"
)
// Logger is the interface expected by [Finisher].Log.
//
// It allows using any loggers which implement the Infof() and Errorf() methods.
type Logger interface {
Infof(format string, v ...interface{})
Errorf(format string, v ...interface{})
}
// default logger
type defaultLogger struct{}
func (l *defaultLogger) Infof(format string, v ...interface{}) {
log.Printf(format, v...)
}
func (l *defaultLogger) Errorf(format string, v ...interface{}) {
l.Infof(format, v...)
}
// stdout logger
type stdoutLogger struct{}
func (l *stdoutLogger) Infof(format string, v ...interface{}) {
fmt.Printf(format+"\n", v...)
}
func (l *stdoutLogger) Errorf(format string, v ...interface{}) {
l.Infof(format, v...)
}