-
Notifications
You must be signed in to change notification settings - Fork 2
/
message.go
67 lines (59 loc) · 1.23 KB
/
message.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
57
58
59
60
61
62
63
64
65
66
67
package zerolog
import (
"fmt"
"github.com/rs/zerolog"
"github.com/tliron/kutil/logging"
)
//
// Message
//
type Message struct {
event *zerolog.Event
}
func NewMessage(event *zerolog.Event) logging.Message {
return &Message{event: event}
}
// logging.Message interface
func (self *Message) Set(key string, value any) logging.Message {
switch value_ := value.(type) {
case string:
self.event.Str(key, value_)
case int:
self.event.Int(key, value_)
case int64:
self.event.Int64(key, value_)
case int32:
self.event.Int32(key, value_)
case int16:
self.event.Int16(key, value_)
case int8:
self.event.Int8(key, value_)
case uint:
self.event.Uint(key, value_)
case uint64:
self.event.Uint64(key, value_)
case uint32:
self.event.Uint32(key, value_)
case uint16:
self.event.Uint16(key, value_)
case uint8:
self.event.Uint8(key, value_)
case float64:
self.event.Float64(key, value_)
case float32:
self.event.Float32(key, value_)
case bool:
self.event.Bool(key, value_)
case []byte:
self.event.Bytes(key, value_)
case fmt.Stringer:
self.event.Stringer(key, value_)
default:
self.event.Interface(key, value_)
}
return self
}
// logging.Message interface
func (self *Message) Send() {
self.event.Send()
}