-
Notifications
You must be signed in to change notification settings - Fork 3
/
properties.go
55 lines (47 loc) · 1.6 KB
/
properties.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
package log
import (
"github.com/rs/zerolog"
)
// Property contains an element of the log, usually a key-value pair.
type Property struct {
impl *zerolog.Event
}
func newLoggerProperty(impl *zerolog.Event) *Property {
return &Property{
impl: impl,
}
}
// Properties adds an entire sub-document of type Property to the log.
func (lf *Property) Properties(fields *Field) *Property {
return lf.doc("properties", fields)
}
// Details adds the property 'details' with the val as a string to the log.
// This is a terminating Property that signals that the log statement is complete
// and can now be sent to the output.
//
// NOTICE: once this method is called, the *Property should be disposed.
// Calling Details twice can have unexpected results.
func (lf *Property) Details(details string) {
lf.impl.Msg(details)
}
// Detailsf adds the property 'details' with the format and args to the log.
// This is a terminating Property that signals that the log statement is complete
// and can now be sent to the output.
//
// NOTICE: once this method is called, the *Property should be disposed.
// Calling Detailsf twice can have unexpected results.
func (lf *Property) Detailsf(format string, v ...interface{}) {
lf.impl.Msgf(format, v...)
}
// Send terminates the log and signals that it is now complete and can be
// sent to the output.
//
// NOTICE: once this method is called, the *Property should be disposed.
// Calling Send twice can have unexpected results.
func (lf *Property) Send() {
lf.impl.Send()
}
func (lf *Property) doc(key string, fields *Field) *Property {
lf.impl = lf.impl.Dict(key, fields.impl)
return lf
}