-
Notifications
You must be signed in to change notification settings - Fork 3
/
logger.go
54 lines (47 loc) · 1.01 KB
/
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
44
45
46
47
48
49
50
51
52
53
54
package ammana
import (
"io"
"io/ioutil"
"log"
"os"
)
//logger
type logger struct {
traceHandle io.Writer
infoHandle io.Writer
warningHandle io.Writer
errorHandle io.Writer
}
//newLogger, logger constructor
func newLogger() *logger {
return &logger{
traceHandle: ioutil.Discard,
infoHandle: os.Stdout,
warningHandle: os.Stdout,
errorHandle: os.Stderr,
}
}
//trace
func (l *logger) trace() *log.Logger {
return log.New(l.traceHandle,
"TRACE: ",
log.Ldate|log.Ltime|log.Lshortfile)
}
//info
func (l *logger) info() *log.Logger {
return log.New(l.infoHandle,
"INFO: ",
log.Ldate|log.Ltime|log.Lshortfile)
}
//warning
func (l *logger) warning() *log.Logger {
return log.New(l.warningHandle,
"WARNING: ",
log.Ldate|log.Ltime|log.Lshortfile)
}
//error
func (l *logger) error() *log.Logger {
return log.New(l.errorHandle,
"ERROR: ",
log.Ldate|log.Ltime|log.Lshortfile)
}