diff --git a/hack/vendor.sh b/hack/vendor.sh index b1087c767c..b97f4077ab 100755 --- a/hack/vendor.sh +++ b/hack/vendor.sh @@ -71,7 +71,7 @@ clone git github.com/golang/protobuf 68415e7123da32b07eab49c96d2c4d6158360e9b # gelf logging driver deps clone git github.com/Graylog2/go-gelf aab2f594e4585d43468ac57287b0dece9d806883 -clone git github.com/fluent/fluent-logger-golang v1.0.0 +clone git github.com/fluent/fluent-logger-golang v1.1.0 # fluent-logger-golang deps clone git github.com/philhofer/fwd 899e4efba8eaa1fea74175308f3fae18ff3319fa clone git github.com/tinylib/msgp 75ee40d2601edf122ef667e2a07d600d4c44490c diff --git a/vendor/src/github.com/fluent/fluent-logger-golang/fluent/fluent.go b/vendor/src/github.com/fluent/fluent-logger-golang/fluent/fluent.go index ce65cae639..1647e9e9e6 100644 --- a/vendor/src/github.com/fluent/fluent-logger-golang/fluent/fluent.go +++ b/vendor/src/github.com/fluent/fluent-logger-golang/fluent/fluent.go @@ -14,6 +14,8 @@ import ( const ( defaultHost = "127.0.0.1" + defaultNetwork = "tcp" + defaultSocketPath = "" defaultPort = 24224 defaultTimeout = 3 * time.Second defaultBufferLimit = 8 * 1024 * 1024 @@ -23,13 +25,16 @@ const ( ) type Config struct { - FluentPort int - FluentHost string - Timeout time.Duration - BufferLimit int - RetryWait int - MaxRetry int - TagPrefix string + FluentPort int + FluentHost string + FluentNetwork string + FluentSocketPath string + Timeout time.Duration + BufferLimit int + RetryWait int + MaxRetry int + TagPrefix string + AsyncConnect bool } type Fluent struct { @@ -42,12 +47,18 @@ type Fluent struct { // New creates a new Logger. func New(config Config) (f *Fluent, err error) { + if config.FluentNetwork == "" { + config.FluentNetwork = defaultNetwork + } if config.FluentHost == "" { config.FluentHost = defaultHost } if config.FluentPort == 0 { config.FluentPort = defaultPort } + if config.FluentSocketPath == "" { + config.FluentSocketPath = defaultSocketPath + } if config.Timeout == 0 { config.Timeout = defaultTimeout } @@ -60,8 +71,13 @@ func New(config Config) (f *Fluent, err error) { if config.MaxRetry == 0 { config.MaxRetry = defaultMaxRetry } - f = &Fluent{Config: config, reconnecting: false} - err = f.connect() + if config.AsyncConnect { + f = &Fluent{Config: config, reconnecting: true} + f.reconnect() + } else { + f = &Fluent{Config: config, reconnecting: false} + err = f.connect() + } return } @@ -171,9 +187,9 @@ func (f *Fluent) EncodeData(tag string, tm time.Time, message interface{}) (data // Close closes the connection. func (f *Fluent) Close() (err error) { if len(f.pending) > 0 { - _ = f.send() + err = f.send() } - err = f.close() + f.close() return } @@ -194,7 +210,14 @@ func (f *Fluent) close() (err error) { // connect establishes a new connection using the specified transport. func (f *Fluent) connect() (err error) { - f.conn, err = net.DialTimeout("tcp", f.Config.FluentHost+":"+strconv.Itoa(f.Config.FluentPort), f.Config.Timeout) + switch f.Config.FluentNetwork { + case "tcp": + f.conn, err = net.DialTimeout(f.Config.FluentNetwork, f.Config.FluentHost+":"+strconv.Itoa(f.Config.FluentPort), f.Config.Timeout) + case "unix": + f.conn, err = net.DialTimeout(f.Config.FluentNetwork, f.Config.FluentSocketPath, f.Config.Timeout) + default: + err = net.UnknownNetworkError(f.Config.FluentNetwork) + } return } diff --git a/vendor/src/github.com/fluent/fluent-logger-golang/fluent/version.go b/vendor/src/github.com/fluent/fluent-logger-golang/fluent/version.go index 135e1e51af..3d8ad3ee11 100644 --- a/vendor/src/github.com/fluent/fluent-logger-golang/fluent/version.go +++ b/vendor/src/github.com/fluent/fluent-logger-golang/fluent/version.go @@ -1,3 +1,3 @@ package fluent -const Version = "1.0.0" +const Version = "1.1.0"