-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlogger.go
49 lines (40 loc) · 965 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
45
46
47
48
49
package gologger
import (
"net/http"
)
type Fields map[string]interface{}
type Clonable interface {
Clone() interface{}
}
func (f Fields) Clone() Fields {
if f == nil {
return nil
}
clone := Fields{}
for key, value := range f {
if clonable, ok := value.(Clonable); ok {
clone[key] = clonable.Clone()
} else {
clone[key] = value
}
}
return clone
}
type Logger interface {
WithField(key string, value interface{}) Logger
WithFields(fields Fields) Logger
WithError(err error) Logger
WithRequest(req *http.Request) Logger
Log(level Level, args ...interface{})
Debugf(format string, args ...interface{})
Infof(format string, args ...interface{})
Warningf(format string, args ...interface{})
Errorf(format string, args ...interface{})
Fatalf(format string, args ...interface{})
Debug(args ...interface{})
Info(args ...interface{})
Warning(args ...interface{})
Error(args ...interface{})
Fatal(args ...interface{})
Close()
}