-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathevent.go
56 lines (45 loc) · 1.19 KB
/
event.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 zerolog
import (
"time"
"github.com/facebookincubator/go-belt/tool/logger"
)
type Event struct {
Level logger.Level
Logger *Logger
}
func (ev *Event) CallerSkipFrame(frameCount int) *Event {
return ev
}
func (ev *Event) Msg(message string) {
ev.Logger.Logger.Log(ev.Level, message)
}
func (ev *Event) Msgf(format string, args ...any) {
ev.Logger.Logger.Logf(ev.Level, format, args...)
}
func (ev *Event) Str(key string, value string) *Event {
return &Event{
Level: ev.Level,
Logger: &Logger{Logger: ev.Logger.Logger.WithField(key, value)},
}
}
func (ev *Event) Int(key string, value int) *Event {
return &Event{
Level: ev.Level,
Logger: &Logger{Logger: ev.Logger.Logger.WithField(key, value)},
}
}
func (ev *Event) Int64(key string, value int64) *Event {
return &Event{
Level: ev.Level,
Logger: &Logger{Logger: ev.Logger.Logger.WithField(key, value)},
}
}
func (ev *Event) Dur(key string, value time.Duration) *Event {
return &Event{
Level: ev.Level,
Logger: &Logger{Logger: ev.Logger.Logger.WithField(key, value)},
}
}
func (ev *Event) Err(err error) *Event {
return &Event{Level: logger.LevelError, Logger: &Logger{ev.Logger.Logger.WithField("error", err)}}
}