add send function for convenience (#164)
This commit is contained in:
parent
60d4b07b61
commit
77a1695358
|
@ -82,9 +82,14 @@ func main() {
|
||||||
Str("Scale", "833 cents").
|
Str("Scale", "833 cents").
|
||||||
Float64("Interval", 833.09).
|
Float64("Interval", 833.09).
|
||||||
Msg("Fibonacci is everywhere")
|
Msg("Fibonacci is everywhere")
|
||||||
|
|
||||||
|
log.Debug().
|
||||||
|
Str("Name", "Tom").
|
||||||
|
Send()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Output: {"time":1524104936,"level":"debug","Scale":"833 cents","Interval":833.09,"message":"Fibonacci is everywhere"}
|
// Output: {"level":"debug","Scale":"833 cents","Interval":833.09,"time":1562212768,"message":"Fibonacci is everywhere"}
|
||||||
|
// Output: {"level":"debug","Name":"Tom","time":1562212768}
|
||||||
```
|
```
|
||||||
|
|
||||||
> You'll note in the above example that when adding contextual fields, the fields are strongly typed. You can find the full list of supported fields [here](#standard-types)
|
> You'll note in the above example that when adding contextual fields, the fields are strongly typed. You can find the full list of supported fields [here](#standard-types)
|
||||||
|
|
10
event.go
10
event.go
|
@ -105,6 +105,16 @@ func (e *Event) Msg(msg string) {
|
||||||
e.msg(msg)
|
e.msg(msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Send just like call Msg("")
|
||||||
|
//
|
||||||
|
// NOTICE: once this method is called, the *Event should be disposed.
|
||||||
|
func (e *Event) Send() {
|
||||||
|
if e == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
e.msg("")
|
||||||
|
}
|
||||||
|
|
||||||
// Msgf sends the event with formated msg added as the message field if not empty.
|
// Msgf sends the event with formated msg added as the message field if not empty.
|
||||||
//
|
//
|
||||||
// NOTICE: once this methid is called, the *Event should be disposed.
|
// NOTICE: once this methid is called, the *Event should be disposed.
|
||||||
|
|
Loading…
Reference in New Issue