-
Notifications
You must be signed in to change notification settings - Fork 246
/
log.go
91 lines (75 loc) · 3.81 KB
/
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
package anaconda
import (
"log"
"os"
)
// The Logger interface provides optional logging ability for the streaming API.
// It can also be used to log the rate limiting headers if desired.
type Logger interface {
Fatal(args ...interface{})
Fatalf(format string, args ...interface{})
Panic(args ...interface{})
Panicf(format string, args ...interface{})
// Log functions
Critical(args ...interface{})
Criticalf(format string, args ...interface{})
Error(args ...interface{})
Errorf(format string, args ...interface{})
Warning(args ...interface{})
Warningf(format string, args ...interface{})
Notice(args ...interface{})
Noticef(format string, args ...interface{})
Info(args ...interface{})
Infof(format string, args ...interface{})
Debug(args ...interface{})
Debugf(format string, args ...interface{})
}
// SetLogger sets the Logger used by the API client.
// The default logger is silent. BasicLogger will log to STDERR
// using the log package from the standard library.
func (c *TwitterApi) SetLogger(l Logger) {
c.Log = l
}
type silentLogger struct {
}
func (_ silentLogger) Fatal(_ ...interface{}) {}
func (_ silentLogger) Fatalf(_ string, _ ...interface{}) {}
func (_ silentLogger) Panic(_ ...interface{}) {}
func (_ silentLogger) Panicf(_ string, _ ...interface{}) {}
func (_ silentLogger) Critical(_ ...interface{}) {}
func (_ silentLogger) Criticalf(_ string, _ ...interface{}) {}
func (_ silentLogger) Error(_ ...interface{}) {}
func (_ silentLogger) Errorf(_ string, _ ...interface{}) {}
func (_ silentLogger) Warning(_ ...interface{}) {}
func (_ silentLogger) Warningf(_ string, _ ...interface{}) {}
func (_ silentLogger) Notice(_ ...interface{}) {}
func (_ silentLogger) Noticef(_ string, _ ...interface{}) {}
func (_ silentLogger) Info(_ ...interface{}) {}
func (_ silentLogger) Infof(_ string, _ ...interface{}) {}
func (_ silentLogger) Debug(_ ...interface{}) {}
func (_ silentLogger) Debugf(format string, _ ...interface{}) {}
// BasicLogger is the equivalent of using log from the standard
// library to print to STDERR.
var BasicLogger Logger
type basicLogger struct {
log *log.Logger //func New(out io.Writer, prefix string, flag int) *Logger
}
func init() {
BasicLogger = &basicLogger{log: log.New(os.Stderr, log.Prefix(), log.LstdFlags)}
}
func (l basicLogger) Fatal(items ...interface{}) { l.log.Fatal(items...) }
func (l basicLogger) Fatalf(s string, items ...interface{}) { l.log.Fatalf(s, items...) }
func (l basicLogger) Panic(items ...interface{}) { l.log.Panic(items...) }
func (l basicLogger) Panicf(s string, items ...interface{}) { l.log.Panicf(s, items...) }
func (l basicLogger) Critical(items ...interface{}) { l.log.Print(items...) }
func (l basicLogger) Criticalf(s string, items ...interface{}) { l.log.Printf(s, items...) }
func (l basicLogger) Error(items ...interface{}) { l.log.Print(items...) }
func (l basicLogger) Errorf(s string, items ...interface{}) { l.log.Printf(s, items...) }
func (l basicLogger) Warning(items ...interface{}) { l.log.Print(items...) }
func (l basicLogger) Warningf(s string, items ...interface{}) { l.log.Printf(s, items...) }
func (l basicLogger) Notice(items ...interface{}) { l.log.Print(items...) }
func (l basicLogger) Noticef(s string, items ...interface{}) { l.log.Printf(s, items...) }
func (l basicLogger) Info(items ...interface{}) { l.log.Print(items...) }
func (l basicLogger) Infof(s string, items ...interface{}) { l.log.Printf(s, items...) }
func (l basicLogger) Debug(items ...interface{}) { l.log.Print(items...) }
func (l basicLogger) Debugf(s string, items ...interface{}) { l.log.Printf(s, items...) }