forked from yeqown/fasthttp-reverse-proxy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
logger.go
44 lines (34 loc) · 805 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
44
package proxy
import (
"fmt"
)
type __Logger interface {
Printf(format string, args ...interface{})
}
type nopLogger struct{}
func (n *nopLogger) Printf(format string, args ...interface{}) {
// if format not end with '\n', then append it
if format[len(format)-1] != '\n' {
format += "\n"
}
fmt.Printf(format, args...)
}
func debugF(debug bool, logger __Logger, format string, args ...interface{}) {
if logger == nil || !debug {
return
}
logger.Printf("[debug] "+format, args...)
}
//func infoF(logger __Logger, format string, args ...interface{}) {
// if logger == nil {
// return
// }
//
// logger.Printf("[info] "+format, args...)
//}
func errorF(logger __Logger, format string, args ...interface{}) {
if logger == nil {
return
}
logger.Printf("[error] "+format, args...)
}