mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge pull request #40098 from thaJeztah/bump_gelf
bump Graylog2/go-gelf to 1550ee647df0510058c9d67a45c56f18911d80b8
This commit is contained in:
commit
098144291d
3 changed files with 22 additions and 13 deletions
|
@ -90,7 +90,7 @@ github.com/coreos/go-systemd 39ca1b05acc7ad1220e09f133283
|
||||||
github.com/godbus/dbus 5f6efc7ef2759c81b7ba876593971bfce311eab3 # v4.0.0
|
github.com/godbus/dbus 5f6efc7ef2759c81b7ba876593971bfce311eab3 # v4.0.0
|
||||||
|
|
||||||
# gelf logging driver deps
|
# gelf logging driver deps
|
||||||
github.com/Graylog2/go-gelf 4143646226541087117ff2f83334ea48b3201841
|
github.com/Graylog2/go-gelf 1550ee647df0510058c9d67a45c56f18911d80b8 # v2 branch
|
||||||
|
|
||||||
# fluent-logger-golang deps
|
# fluent-logger-golang deps
|
||||||
github.com/fluent/fluent-logger-golang 7a6c9dcd7f14c2ed5d8c55c11b894e5455ee311b # v1.4.0
|
github.com/fluent/fluent-logger-golang 7a6c9dcd7f14c2ed5d8c55c11b894e5455ee311b # v1.4.0
|
||||||
|
|
29
vendor/github.com/Graylog2/go-gelf/gelf/message.go
generated
vendored
29
vendor/github.com/Graylog2/go-gelf/gelf/message.go
generated
vendored
|
@ -3,6 +3,7 @@ package gelf
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -84,29 +85,35 @@ func (m *Message) UnmarshalJSON(data []byte) error {
|
||||||
m.Extra[k] = v
|
m.Extra[k] = v
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ok := true
|
||||||
switch k {
|
switch k {
|
||||||
case "version":
|
case "version":
|
||||||
m.Version = v.(string)
|
m.Version, ok = v.(string)
|
||||||
case "host":
|
case "host":
|
||||||
m.Host = v.(string)
|
m.Host, ok = v.(string)
|
||||||
case "short_message":
|
case "short_message":
|
||||||
m.Short = v.(string)
|
m.Short, ok = v.(string)
|
||||||
case "full_message":
|
case "full_message":
|
||||||
m.Full = v.(string)
|
m.Full, ok = v.(string)
|
||||||
case "timestamp":
|
case "timestamp":
|
||||||
m.TimeUnix = v.(float64)
|
m.TimeUnix, ok = v.(float64)
|
||||||
case "level":
|
case "level":
|
||||||
m.Level = int32(v.(float64))
|
var level float64
|
||||||
|
level, ok = v.(float64)
|
||||||
|
m.Level = int32(level)
|
||||||
case "facility":
|
case "facility":
|
||||||
m.Facility = v.(string)
|
m.Facility, ok = v.(string)
|
||||||
|
}
|
||||||
|
|
||||||
|
if !ok {
|
||||||
|
return fmt.Errorf("invalid type for field %s", k)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Message) toBytes() (messageBytes []byte, err error) {
|
func (m *Message) toBytes(buf *bytes.Buffer) (messageBytes []byte, err error) {
|
||||||
buf := newBuffer()
|
|
||||||
defer bufPool.Put(buf)
|
|
||||||
if err = m.MarshalJSONBuf(buf); err != nil {
|
if err = m.MarshalJSONBuf(buf); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -134,7 +141,7 @@ func constructMessage(p []byte, hostname string, facility string, file string, l
|
||||||
Host: hostname,
|
Host: hostname,
|
||||||
Short: string(short),
|
Short: string(short),
|
||||||
Full: string(full),
|
Full: string(full),
|
||||||
TimeUnix: float64(time.Now().Unix()),
|
TimeUnix: float64(time.Now().UnixNano()) / float64(time.Second),
|
||||||
Level: 6, // info
|
Level: 6, // info
|
||||||
Facility: facility,
|
Facility: facility,
|
||||||
Extra: map[string]interface{}{
|
Extra: map[string]interface{}{
|
||||||
|
|
4
vendor/github.com/Graylog2/go-gelf/gelf/tcpwriter.go
generated
vendored
4
vendor/github.com/Graylog2/go-gelf/gelf/tcpwriter.go
generated
vendored
|
@ -43,7 +43,9 @@ func NewTCPWriter(addr string) (*TCPWriter, error) {
|
||||||
// filled out appropriately. In general, clients will want to use
|
// filled out appropriately. In general, clients will want to use
|
||||||
// Write, rather than WriteMessage.
|
// Write, rather than WriteMessage.
|
||||||
func (w *TCPWriter) WriteMessage(m *Message) (err error) {
|
func (w *TCPWriter) WriteMessage(m *Message) (err error) {
|
||||||
messageBytes, err := m.toBytes()
|
buf := newBuffer()
|
||||||
|
defer bufPool.Put(buf)
|
||||||
|
messageBytes, err := m.toBytes(buf)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue