-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathlog.go
More file actions
23 lines (18 loc) · 747 Bytes
/
log.go
File metadata and controls
23 lines (18 loc) · 747 Bytes
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 ...any)
// Printf calls Output to print to the standard logger. Arguments are handled in the manner of fmt.Printf.
Printf(format string, v ...any)
}
// emptyLogger to discard all logs by default
type emptyLogger struct{}
func (l *emptyLogger) Print(v ...any) {}
func (l *emptyLogger) Printf(format string, v ...any) {}