forked from hpcloud/tail
-
Notifications
You must be signed in to change notification settings - Fork 0
/
logger.go
43 lines (36 loc) · 913 Bytes
/
logger.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
package tail
import (
"io/ioutil"
"log"
"os"
)
type Logger interface {
Fatal(v ...interface{})
Fatalf(format string, v ...interface{})
Fatalln(v ...interface{})
Panic(v ...interface{})
Panicf(format string, v ...interface{})
Panicln(v ...interface{})
Print(v ...interface{})
Printf(format string, v ...interface{})
Println(v ...interface{})
Debugf(format string, v ...interface{})
Debug(v ...interface{})
}
type logger struct {
*log.Logger
}
// NewDefaultLogger creates new logger when Config.Logger == nil.
func NewDefaultLogger() Logger {
return &logger{Logger: log.New(os.Stderr, "", log.LstdFlags)}
}
// NewDiscardingLogger creates new disabled logger.
func NewDiscardingLogger() Logger {
return &logger{Logger: log.New(ioutil.Discard, "", 0)}
}
func (l *logger) Debugf(format string, v ...interface{}) {
l.Printf(format, v)
}
func (l *logger) Debug(v ...interface{}) {
l.Print(v)
}