forked from Tinsane/tracelog
-
Notifications
You must be signed in to change notification settings - Fork 7
/
error_logger.go
56 lines (45 loc) · 1.02 KB
/
error_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
55
56
package tracelog
import (
"io"
"log"
)
type errorLogger struct {
*log.Logger
}
func NewErrorLogger(out io.Writer, prefix string) *errorLogger {
return &errorLogger{log.New(out, prefix, timeFlags)}
}
func (logger *errorLogger) PanicError(err error) {
logger.Panicf(GetErrorFormatter(), err)
}
func (logger *errorLogger) PanicfOnError(format string, err error) {
if err != nil {
logger.Panicf(format, err)
}
}
func (logger *errorLogger) PanicOnError(err error) {
if err != nil {
logger.PanicError(err)
}
}
func (logger *errorLogger) FatalError(err error) {
logger.Fatalf(GetErrorFormatter(), err)
}
func (logger *errorLogger) FatalfOnError(format string, err error) {
if err != nil {
logger.Fatalf(format, err)
}
}
func (logger *errorLogger) FatalOnError(err error) {
if err != nil {
logger.FatalError(err)
}
}
func (logger *errorLogger) PrintError(err error) {
logger.Printf(GetErrorFormatter()+"\n", err)
}
func (logger *errorLogger) PrintOnError(err error) {
if err != nil {
logger.PrintError(err)
}
}