-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathlog.go
More file actions
38 lines (28 loc) · 709 Bytes
/
log.go
File metadata and controls
38 lines (28 loc) · 709 Bytes
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 ...any)
Errorf(format string, v ...any)
}
// default logger
type defaultLogger struct{}
func (l *defaultLogger) Infof(format string, v ...any) {
log.Printf(format, v...)
}
func (l *defaultLogger) Errorf(format string, v ...any) {
l.Infof(format, v...)
}
// stdout logger
type stdoutLogger struct{}
func (l *stdoutLogger) Infof(format string, v ...any) {
fmt.Printf(format+"\n", v...)
}
func (l *stdoutLogger) Errorf(format string, v ...any) {
l.Infof(format, v...)
}