-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathlog.go
50 lines (39 loc) · 791 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
39
40
41
42
43
44
45
46
47
48
49
50
package paypal
import (
"log"
"os"
)
func init() {
SetLogger(log.New(os.Stdout, "", log.LstdFlags|log.Llongfile))
}
type Logger interface {
SetPrefix(prefix string)
Prefix() string
Println(args ...interface{})
Printf(format string, args ...interface{})
Output(calldepth int, s string) error
}
var logger Logger
func SetLogger(l Logger) {
if l == nil {
l = &nilLogger{}
}
if l.Prefix() == "" {
l.SetPrefix("[paypal] ")
}
logger = l
}
type nilLogger struct {
}
func (log *nilLogger) SetPrefix(prefix string) {
}
func (log *nilLogger) Prefix() string {
return ""
}
func (log *nilLogger) Println(args ...interface{}) {
}
func (log *nilLogger) Printf(format string, args ...interface{}) {
}
func (log *nilLogger) Output(calldepth int, s string) error {
return nil
}