diff --git a/vendor/github.com/inconshreveable/log15/.travis.yml b/vendor/github.com/inconshreveable/log15/.travis.yml deleted file mode 100644 index ff5d75e72b9..00000000000 --- a/vendor/github.com/inconshreveable/log15/.travis.yml +++ /dev/null @@ -1,10 +0,0 @@ -language: go - -go: - - 1.1 - - 1.2 - - 1.3 - - 1.4 - - 1.5 - - 1.6 - - tip diff --git a/vendor/github.com/inconshreveable/log15/README.md b/vendor/github.com/inconshreveable/log15/README.md index 8ccd5a38d05..0951b21cb53 100644 --- a/vendor/github.com/inconshreveable/log15/README.md +++ b/vendor/github.com/inconshreveable/log15/README.md @@ -2,7 +2,7 @@ # log15 [![godoc reference](https://godoc.org/github.com/inconshreveable/log15?status.png)](https://godoc.org/github.com/inconshreveable/log15) [![Build Status](https://travis-ci.org/inconshreveable/log15.svg?branch=master)](https://travis-ci.org/inconshreveable/log15) -Package log15 provides an opinionated, simple toolkit for best-practice logging in Go (golang) that is both human and machine readable. It is modeled after the Go standard library's [`io`](http://golang.org/pkg/io/) and [`net/http`](http://golang.org/pkg/net/http/) packages and is an alternative to the standard library's [`log`](http://golang.org/pkg/log/) package. +Package log15 provides an opinionated, simple toolkit for best-practice logging in Go (golang) that is both human and machine readable. It is modeled after the Go standard library's [`io`](http://golang.org/pkg/io/) and [`net/http`](http://golang.org/pkg/net/http/) packages and is an alternative to the standard library's [`log`](http://golang.org/pkg/log/) package. ## Features - A simple, easy-to-understand API @@ -30,7 +30,7 @@ import log "github.com/inconshreveable/log15" // all loggers can have key/value context srvlog := log.New("module", "app/server") -// all log messages can have key/value context +// all log messages can have key/value context srvlog.Warn("abnormal conn rate", "rate", curRate, "low", lowRate, "high", highRate) // child loggers with inherited context @@ -45,7 +45,14 @@ srvlog.SetHandler(log.MultiHandler( log.StreamHandler(os.Stderr, log.LogfmtFormat()), log.LvlFilterHandler( log.LvlError, - log.Must.FileHandler("errors.json", log.JsonFormat()))) + log.Must.FileHandler("errors.json", log.JsonFormat())))) +``` + +Will result in output that looks like this: + +``` +WARN[06-17|21:58:10] abnormal conn rate module=app/server rate=0.500 low=0.100 high=0.800 +INFO[06-17|21:58:10] connection open module=app/server raddr=10.0.0.1 ``` ## Breaking API Changes diff --git a/vendor/github.com/inconshreveable/log15/doc.go b/vendor/github.com/inconshreveable/log15/doc.go index a5cc87419c4..ab7e090d95f 100644 --- a/vendor/github.com/inconshreveable/log15/doc.go +++ b/vendor/github.com/inconshreveable/log15/doc.go @@ -97,7 +97,7 @@ context, CallerFileHandler, CallerFuncHandler and CallerStackHandler. Here's an example that adds the source file and line number of each logging call to the context. - h := log.CallerFileHandler(log.StdoutHandler()) + h := log.CallerFileHandler(log.StdoutHandler) log.Root().SetHandler(h) ... log.Error("open file", "err", err) @@ -108,7 +108,7 @@ This will output a line that looks like: Here's an example that logs the call stack rather than just the call site. - h := log.CallerStackHandler("%+v", log.StdoutHandler()) + h := log.CallerStackHandler("%+v", log.StdoutHandler) log.Root().SetHandler(h) ... log.Error("open file", "err", err) diff --git a/vendor/github.com/inconshreveable/log15/format.go b/vendor/github.com/inconshreveable/log15/format.go index 3468f3048f3..f31b42fcaa3 100644 --- a/vendor/github.com/inconshreveable/log15/format.go +++ b/vendor/github.com/inconshreveable/log15/format.go @@ -7,6 +7,7 @@ import ( "reflect" "strconv" "strings" + "sync" "time" ) @@ -108,7 +109,9 @@ func logfmt(buf *bytes.Buffer, ctx []interface{}, color int) { if color > 0 { fmt.Fprintf(buf, "\x1b[%dm%s\x1b[0m=%s", color, k, v) } else { - fmt.Fprintf(buf, "%s=%s", k, v) + buf.WriteString(k) + buf.WriteByte('=') + buf.WriteString(v) } } @@ -205,6 +208,12 @@ func formatLogfmtValue(value interface{}) string { return "nil" } + if t, ok := value.(time.Time); ok { + // Performance optimization: No need for escaping since the provided + // timeFormat doesn't have any escape characters, and escaping is + // expensive. + return t.Format(timeFormat) + } value = formatShared(value) switch v := value.(type) { case bool: @@ -222,36 +231,49 @@ func formatLogfmtValue(value interface{}) string { } } +var stringBufPool = sync.Pool{ + New: func() interface{} { return new(bytes.Buffer) }, +} + func escapeString(s string) string { - needQuotes := false - e := bytes.Buffer{} - e.WriteByte('"') + needsQuotes := false + needsEscape := false for _, r := range s { if r <= ' ' || r == '=' || r == '"' { - needQuotes = true + needsQuotes = true } - + if r == '\\' || r == '"' || r == '\n' || r == '\r' || r == '\t' { + needsEscape = true + } + } + if needsEscape == false && needsQuotes == false { + return s + } + e := stringBufPool.Get().(*bytes.Buffer) + e.WriteByte('"') + for _, r := range s { switch r { case '\\', '"': e.WriteByte('\\') e.WriteByte(byte(r)) case '\n': - e.WriteByte('\\') - e.WriteByte('n') + e.WriteString("\\n") case '\r': - e.WriteByte('\\') - e.WriteByte('r') + e.WriteString("\\r") case '\t': - e.WriteByte('\\') - e.WriteByte('t') + e.WriteString("\\t") default: e.WriteRune(r) } } e.WriteByte('"') - start, stop := 0, e.Len() - if !needQuotes { - start, stop = 1, stop-1 + var ret string + if needsQuotes { + ret = e.String() + } else { + ret = string(e.Bytes()[1 : e.Len()-1]) } - return string(e.Bytes()[start:stop]) + e.Reset() + stringBufPool.Put(e) + return ret } diff --git a/vendor/github.com/inconshreveable/log15/handler.go b/vendor/github.com/inconshreveable/log15/handler.go index 43205608cc1..fa4570a69ec 100644 --- a/vendor/github.com/inconshreveable/log15/handler.go +++ b/vendor/github.com/inconshreveable/log15/handler.go @@ -180,7 +180,7 @@ func MatchFilterHandler(key string, value interface{}, h Handler) Handler { // level to the wrapped Handler. For example, to only // log Error/Crit records: // -// log.LvlFilterHandler(log.Error, log.StdoutHandler) +// log.LvlFilterHandler(log.LvlError, log.StdoutHandler) // func LvlFilterHandler(maxLvl Lvl, h Handler) Handler { return FilterHandler(func(r *Record) (pass bool) { diff --git a/vendor/github.com/inconshreveable/log15/syslog.go b/vendor/github.com/inconshreveable/log15/syslog.go index 5f95f99f1ee..813481b5669 100644 --- a/vendor/github.com/inconshreveable/log15/syslog.go +++ b/vendor/github.com/inconshreveable/log15/syslog.go @@ -14,7 +14,7 @@ func SyslogHandler(priority syslog.Priority, tag string, fmtr Format) (Handler, return sharedSyslog(fmtr, wr, err) } -// SyslogHandler opens a connection to a log daemon over the network and writes +// SyslogNetHandler opens a connection to a log daemon over the network and writes // all log records to it. func SyslogNetHandler(net, addr string, priority syslog.Priority, tag string, fmtr Format) (Handler, error) { wr, err := syslog.Dial(net, addr, priority, tag) diff --git a/vendor/github.com/inconshreveable/log15/term/terminal_darwin.go b/vendor/github.com/inconshreveable/log15/term/terminal_darwin.go index b05de4cb8c8..d8f351b1b1a 100644 --- a/vendor/github.com/inconshreveable/log15/term/terminal_darwin.go +++ b/vendor/github.com/inconshreveable/log15/term/terminal_darwin.go @@ -2,6 +2,7 @@ // Copyright 2013 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build !appengine package term diff --git a/vendor/github.com/inconshreveable/log15/term/terminal_netbsd.go b/vendor/github.com/inconshreveable/log15/term/terminal_netbsd.go new file mode 100644 index 00000000000..f9bb9e1c23b --- /dev/null +++ b/vendor/github.com/inconshreveable/log15/term/terminal_netbsd.go @@ -0,0 +1,7 @@ +package term + +import "syscall" + +const ioctlReadTermios = syscall.TIOCGETA + +type Termios syscall.Termios diff --git a/vendor/github.com/inconshreveable/log15/term/terminal_notwindows.go b/vendor/github.com/inconshreveable/log15/term/terminal_notwindows.go index 87df7d5b029..c9af534f62f 100644 --- a/vendor/github.com/inconshreveable/log15/term/terminal_notwindows.go +++ b/vendor/github.com/inconshreveable/log15/term/terminal_notwindows.go @@ -3,7 +3,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build linux,!appengine darwin freebsd openbsd +// +build linux,!appengine darwin freebsd openbsd netbsd package term diff --git a/vendor/github.com/inconshreveable/log15/term/terminal_solaris.go b/vendor/github.com/inconshreveable/log15/term/terminal_solaris.go new file mode 100644 index 00000000000..033c163246e --- /dev/null +++ b/vendor/github.com/inconshreveable/log15/term/terminal_solaris.go @@ -0,0 +1,9 @@ +package term + +import "golang.org/x/sys/unix" + +// IsTty returns true if the given file descriptor is a terminal. +func IsTty(fd uintptr) bool { + _, err := unix.IoctlGetTermios(int(fd), unix.TCGETA) + return err == nil +} diff --git a/vendor/vendor.json b/vendor/vendor.json index 4e884428eb7..9d80bd38f84 100644 --- a/vendor/vendor.json +++ b/vendor/vendor.json @@ -416,6 +416,18 @@ "revision": "3ab3a8b8831546bd18fd182c20687ca853b2bb13", "revisionTime": "2016-12-15T22:53:35Z" }, + { + "checksumSHA1": "mrmfY0cVu7jvgoIuTRaR8yVVh/M=", + "path": "github.com/inconshreveable/log15", + "revision": "39bacc234bf1afd0b68573e95b45871f67ba2cd4", + "revisionTime": "2017-02-16T22:56:31Z" + }, + { + "checksumSHA1": "oVIIInZXKkcRozJfuH2vWJsAS7s=", + "path": "github.com/inconshreveable/log15/term", + "revision": "39bacc234bf1afd0b68573e95b45871f67ba2cd4", + "revisionTime": "2017-02-16T22:56:31Z" + }, { "checksumSHA1": "BM6ZlNJmtKy3GBoWwg2X55gnZ4A=", "path": "github.com/klauspost/crc32",