forked from anacrolix/torrent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
logging.go
35 lines (27 loc) · 819 Bytes
/
logging.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
package torrent
import "fmt"
// logger is a logger interface compatible with both stdlib and some
// 3rd party loggers.
type logger interface {
Output(int, string) error
}
// implements the additional methods used by the package for logging.
type llog struct {
logger
}
// Println replicates the behaviour of the standard logger.
func (t llog) Println(v ...interface{}) {
t.Output(2, fmt.Sprintln(v...))
}
// Printf replicates the behaviour of the standard logger.
func (t llog) Printf(format string, v ...interface{}) {
t.Output(2, fmt.Sprintf(format, v...))
}
// Print replicates the behaviour of the standard logger.
func (t llog) Print(v ...interface{}) {
t.Output(2, fmt.Sprint(v...))
}
type discard struct{}
func (discard) Output(int, string) error {
return nil
}