-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathlog.go
23 lines (18 loc) · 779 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
package selfupdate
var log Logger = &emptyLogger{}
// SetLogger redirects all logs to the logger defined in parameter.
// By default logs are not sent anywhere.
func SetLogger(logger Logger) {
log = logger
}
// Logger interface. Compatible with standard log.Logger
type Logger interface {
// Print calls Output to print to the standard logger. Arguments are handled in the manner of fmt.Print.
Print(v ...interface{})
// Printf calls Output to print to the standard logger. Arguments are handled in the manner of fmt.Printf.
Printf(format string, v ...interface{})
}
// emptyLogger to discard all logs by default
type emptyLogger struct{}
func (l *emptyLogger) Print(v ...interface{}) {}
func (l *emptyLogger) Printf(format string, v ...interface{}) {}