fixed deps

This commit is contained in:
Liam Galvin 2018-08-08 17:39:48 +01:00
parent 2245f1589a
commit aa8034f266
15 changed files with 269 additions and 54 deletions

8
Gopkg.lock generated
View File

@ -33,7 +33,7 @@
branch = "master" branch = "master"
name = "github.com/liamg/glfont" name = "github.com/liamg/glfont"
packages = ["."] packages = ["."]
revision = "35ed3188e0013938f3ce8689683b860e0d541a81" revision = "1409aed3c17da6d28f211c5e5c52e879abb32fbf"
[[projects]] [[projects]]
name = "github.com/pmezard/go-difflib" name = "github.com/pmezard/go-difflib"
@ -78,8 +78,8 @@
"internal/exit", "internal/exit",
"zapcore" "zapcore"
] ]
revision = "eeedf312bc6c57391d84767a4cd413f02a917974" revision = "ff33455a0e382e8a81d14dd7c922020b6b5e7982"
version = "v1.8.0" version = "v1.9.1"
[[projects]] [[projects]]
branch = "master" branch = "master"
@ -88,7 +88,7 @@
"font", "font",
"math/fixed" "math/fixed"
] ]
revision = "cc896f830cedae125428bc9fe1b0362aa91b3fb1" revision = "c73c2afc3b812cdd6385de5a50616511c4a3d458"
[[projects]] [[projects]]
name = "gopkg.in/yaml.v2" name = "gopkg.in/yaml.v2"

View File

@ -74,9 +74,9 @@ func (f *Font) UpdateResolution(windowWidth int, windowHeight int) {
} }
//Printf draws a string to the screen, takes a list of arguments like printf //Printf draws a string to the screen, takes a list of arguments like printf
func (f *Font) Printf(x, y float32, scale float32, fs string, argv ...interface{}) error { func (f *Font) Print(x, y float32, scale float32, text string) error {
indices := []rune(fmt.Sprintf(fs, argv...)) indices := []rune(text)
if len(indices) == 0 { if len(indices) == 0 {
return nil return nil
@ -163,11 +163,11 @@ func (f *Font) Printf(x, y float32, scale float32, fs string, argv ...interface{
} }
//Width returns the width of a piece of text in pixels //Width returns the width of a piece of text in pixels
func (f *Font) Width(scale float32, fs string, argv ...interface{}) float32 { func (f *Font) Width(scale float32, text string) float32 {
var width float32 var width float32
indices := []rune(fmt.Sprintf(fs, argv...)) indices := []rune(text)
if len(indices) == 0 { if len(indices) == 0 {
return 0 return 0
@ -199,12 +199,12 @@ func (f *Font) Width(scale float32, fs string, argv ...interface{}) float32 {
} }
//Height returns the height of a piece of text in pixels //Height returns the height of a piece of text in pixels
func (f *Font) Width(scale float32, fs string, argv ...interface{}) float32 { func (f *Font) Height(scale float32, text string) float32 {
var baseHeight float32 var baseHeight float32
var height float32 var height float32
indices := []rune(fmt.Sprintf(fs, argv...)) indices := []rune(text)
if len(indices) == 0 { if len(indices) == 0 {
return 0 return 0
@ -232,8 +232,8 @@ func (f *Font) Width(scale float32, fs string, argv ...interface{}) float32 {
ch := f.fontChar[runeIndex-lowChar] ch := f.fontChar[runeIndex-lowChar]
// Now advance cursors for next glyph (note that advance is number of 1/64 pixels) // Now advance cursors for next glyph (note that advance is number of 1/64 pixels)
if ch.height * scale > height { if float32(ch.height) * scale > height {
height = ch.height * scale height = float32(ch.height) * scale
} }
} }

View File

@ -11,7 +11,7 @@ Note that zap only supports the two most recent minor versions of Go.
## Quick Start ## Quick Start
In contexts where performance is nice, but not critical, use the In contexts where performance is nice, but not critical, use the
`SugaredLogger`. It's 4-10x faster than than other structured logging `SugaredLogger`. It's 4-10x faster than other structured logging
packages and includes both structured and `printf`-style APIs. packages and includes both structured and `printf`-style APIs.
```go ```go

4
vendor/go.uber.org/zap/.travis.yml generated vendored
View File

@ -1,8 +1,8 @@
language: go language: go
sudo: false sudo: false
go: go:
- "1.9" - 1.9.x
- "1.10" - 1.10.x
go_import_path: go.uber.org/zap go_import_path: go.uber.org/zap
env: env:
global: global:

19
vendor/go.uber.org/zap/CHANGELOG.md generated vendored
View File

@ -1,5 +1,20 @@
# Changelog # Changelog
## v1.9.1 (06 Aug 2018)
Bugfixes:
* [#614][]: MapObjectEncoder should not ignore empty slices.
## v1.9.0 (19 Jul 2018)
Enhancements:
* [#602][]: Reduce number of allocations when logging with reflection.
* [#572][], [#606][]: Expose a registry for third-party logging sinks.
Thanks to @nfarah86, @AlekSi, @JeanMertz, @philippgille, @etsangsplk, and
@dimroc for their contributions to this release.
## v1.8.0 (13 Apr 2018) ## v1.8.0 (13 Apr 2018)
Enhancements: Enhancements:
@ -284,3 +299,7 @@ upgrade to the upcoming stable release.
[#518]: https://github.com/uber-go/zap/pull/518 [#518]: https://github.com/uber-go/zap/pull/518
[#577]: https://github.com/uber-go/zap/pull/577 [#577]: https://github.com/uber-go/zap/pull/577
[#574]: https://github.com/uber-go/zap/pull/574 [#574]: https://github.com/uber-go/zap/pull/574
[#602]: https://github.com/uber-go/zap/pull/602
[#572]: https://github.com/uber-go/zap/pull/572
[#606]: https://github.com/uber-go/zap/pull/606
[#614]: https://github.com/uber-go/zap/pull/614

1
vendor/go.uber.org/zap/FAQ.md generated vendored
View File

@ -148,6 +148,7 @@ We're aware of the following extensions, but haven't used them ourselves:
| --- | --- | | --- | --- |
| `github.com/tchap/zapext` | Sentry, syslog | | `github.com/tchap/zapext` | Sentry, syslog |
| `github.com/fgrosse/zaptest` | Ginkgo | | `github.com/fgrosse/zaptest` | Ginkgo |
| `github.com/blendle/zapdriver` | Stackdriver |
[go-proverbs]: https://go-proverbs.github.io/ [go-proverbs]: https://go-proverbs.github.io/
[import-path]: https://golang.org/cmd/go/#hdr-Remote_import_paths [import-path]: https://golang.org/cmd/go/#hdr-Remote_import_paths

2
vendor/go.uber.org/zap/README.md generated vendored
View File

@ -11,7 +11,7 @@ Note that zap only supports the two most recent minor versions of Go.
## Quick Start ## Quick Start
In contexts where performance is nice, but not critical, use the In contexts where performance is nice, but not critical, use the
`SugaredLogger`. It's 4-10x faster than than other structured logging `SugaredLogger`. It's 4-10x faster than other structured logging
packages and includes both structured and `printf`-style APIs. packages and includes both structured and `printf`-style APIs.
```go ```go

View File

@ -98,6 +98,15 @@ func (b *Buffer) Write(bs []byte) (int, error) {
return len(bs), nil return len(bs), nil
} }
// TrimNewline trims any final "\n" byte from the end of the buffer.
func (b *Buffer) TrimNewline() {
if i := len(b.bs) - 1; i >= 0 {
if b.bs[i] == '\n' {
b.bs = b.bs[:i]
}
}
}
// Free returns the Buffer to its Pool. // Free returns the Buffer to its Pool.
// //
// Callers must not retain references to the Buffer after calling Free. // Callers must not retain references to the Buffer after calling Free.

6
vendor/go.uber.org/zap/config.go generated vendored
View File

@ -74,10 +74,10 @@ type Config struct {
// EncoderConfig sets options for the chosen encoder. See // EncoderConfig sets options for the chosen encoder. See
// zapcore.EncoderConfig for details. // zapcore.EncoderConfig for details.
EncoderConfig zapcore.EncoderConfig `json:"encoderConfig" yaml:"encoderConfig"` EncoderConfig zapcore.EncoderConfig `json:"encoderConfig" yaml:"encoderConfig"`
// OutputPaths is a list of paths to write logging output to. See Open for // OutputPaths is a list of URLs or file paths to write logging output to.
// details. // See Open for details.
OutputPaths []string `json:"outputPaths" yaml:"outputPaths"` OutputPaths []string `json:"outputPaths" yaml:"outputPaths"`
// ErrorOutputPaths is a list of paths to write internal logger errors to. // ErrorOutputPaths is a list of URLs to write internal logger errors to.
// The default is standard error. // The default is standard error.
// //
// Note that this setting only affects internal errors; for sample code that // Note that this setting only affects internal errors; for sample code that

2
vendor/go.uber.org/zap/doc.go generated vendored
View File

@ -48,7 +48,7 @@
// "attempt", 3, // "attempt", 3,
// "backoff", time.Second, // "backoff", time.Second,
// ) // )
// sugar.Printf("failed to fetch URL: %s", "http://example.com") // sugar.Infof("failed to fetch URL: %s", "http://example.com")
// //
// By default, loggers are unbuffered. However, since zap's low-level APIs // By default, loggers are unbuffered. However, since zap's low-level APIs
// allow buffering, calling Sync before letting your process exit is a good // allow buffering, calling Sync before letting your process exit is a good

View File

@ -48,11 +48,11 @@ func (lvl AtomicLevel) ServeHTTP(w http.ResponseWriter, r *http.Request) {
switch r.Method { switch r.Method {
case "GET": case http.MethodGet:
current := lvl.Level() current := lvl.Level()
enc.Encode(payload{Level: &current}) enc.Encode(payload{Level: &current})
case "PUT": case http.MethodPut:
var req payload var req payload
if errmess := func() string { if errmess := func() string {

161
vendor/go.uber.org/zap/sink.go generated vendored Normal file
View File

@ -0,0 +1,161 @@
// Copyright (c) 2016 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
package zap
import (
"errors"
"fmt"
"io"
"net/url"
"os"
"strings"
"sync"
"go.uber.org/zap/zapcore"
)
const schemeFile = "file"
var (
_sinkMutex sync.RWMutex
_sinkFactories map[string]func(*url.URL) (Sink, error) // keyed by scheme
)
func init() {
resetSinkRegistry()
}
func resetSinkRegistry() {
_sinkMutex.Lock()
defer _sinkMutex.Unlock()
_sinkFactories = map[string]func(*url.URL) (Sink, error){
schemeFile: newFileSink,
}
}
// Sink defines the interface to write to and close logger destinations.
type Sink interface {
zapcore.WriteSyncer
io.Closer
}
type nopCloserSink struct{ zapcore.WriteSyncer }
func (nopCloserSink) Close() error { return nil }
type errSinkNotFound struct {
scheme string
}
func (e *errSinkNotFound) Error() string {
return fmt.Sprintf("no sink found for scheme %q", e.scheme)
}
// RegisterSink registers a user-supplied factory for all sinks with a
// particular scheme.
//
// All schemes must be ASCII, valid under section 3.1 of RFC 3986
// (https://tools.ietf.org/html/rfc3986#section-3.1), and must not already
// have a factory registered. Zap automatically registers a factory for the
// "file" scheme.
func RegisterSink(scheme string, factory func(*url.URL) (Sink, error)) error {
_sinkMutex.Lock()
defer _sinkMutex.Unlock()
if scheme == "" {
return errors.New("can't register a sink factory for empty string")
}
normalized, err := normalizeScheme(scheme)
if err != nil {
return fmt.Errorf("%q is not a valid scheme: %v", scheme, err)
}
if _, ok := _sinkFactories[normalized]; ok {
return fmt.Errorf("sink factory already registered for scheme %q", normalized)
}
_sinkFactories[normalized] = factory
return nil
}
func newSink(rawURL string) (Sink, error) {
u, err := url.Parse(rawURL)
if err != nil {
return nil, fmt.Errorf("can't parse %q as a URL: %v", rawURL, err)
}
if u.Scheme == "" {
u.Scheme = schemeFile
}
_sinkMutex.RLock()
factory, ok := _sinkFactories[u.Scheme]
_sinkMutex.RUnlock()
if !ok {
return nil, &errSinkNotFound{u.Scheme}
}
return factory(u)
}
func newFileSink(u *url.URL) (Sink, error) {
if u.User != nil {
return nil, fmt.Errorf("user and password not allowed with file URLs: got %v", u)
}
if u.Fragment != "" {
return nil, fmt.Errorf("fragments not allowed with file URLs: got %v", u)
}
if u.RawQuery != "" {
return nil, fmt.Errorf("query parameters not allowed with file URLs: got %v", u)
}
// Error messages are better if we check hostname and port separately.
if u.Port() != "" {
return nil, fmt.Errorf("ports not allowed with file URLs: got %v", u)
}
if hn := u.Hostname(); hn != "" && hn != "localhost" {
return nil, fmt.Errorf("file URLs must leave host empty or use localhost: got %v", u)
}
switch u.Path {
case "stdout":
return nopCloserSink{os.Stdout}, nil
case "stderr":
return nopCloserSink{os.Stderr}, nil
}
return os.OpenFile(u.Path, os.O_WRONLY|os.O_APPEND|os.O_CREATE, 0644)
}
func normalizeScheme(s string) (string, error) {
// https://tools.ietf.org/html/rfc3986#section-3.1
s = strings.ToLower(s)
if first := s[0]; 'a' > first || 'z' < first {
return "", errors.New("must start with a letter")
}
for i := 1; i < len(s); i++ { // iterate over bytes, not runes
c := s[i]
switch {
case 'a' <= c && c <= 'z':
continue
case '0' <= c && c <= '9':
continue
case c == '.' || c == '+' || c == '-':
continue
}
return "", fmt.Errorf("may not contain %q", c)
}
return s, nil
}

57
vendor/go.uber.org/zap/writer.go generated vendored
View File

@ -21,21 +21,33 @@
package zap package zap
import ( import (
"fmt"
"io"
"io/ioutil" "io/ioutil"
"os"
"go.uber.org/zap/zapcore" "go.uber.org/zap/zapcore"
"go.uber.org/multierr" "go.uber.org/multierr"
) )
// Open is a high-level wrapper that takes a variadic number of paths, opens or // Open is a high-level wrapper that takes a variadic number of URLs, opens or
// creates each of the specified files, and combines them into a locked // creates each of the specified resources, and combines them into a locked
// WriteSyncer. It also returns any error encountered and a function to close // WriteSyncer. It also returns any error encountered and a function to close
// any opened files. // any opened files.
// //
// Passing no paths returns a no-op WriteSyncer. The special paths "stdout" and // Passing no URLs returns a no-op WriteSyncer. Zap handles URLs without a
// "stderr" are interpreted as os.Stdout and os.Stderr, respectively. // scheme and URLs with the "file" scheme. Third-party code may register
// factories for other schemes using RegisterSink.
//
// URLs with the "file" scheme must use absolute paths on the local
// filesystem. No user, password, port, fragments, or query parameters are
// allowed, and the hostname must be empty or "localhost".
//
// Since it's common to write logs to the local filesystem, URLs without a
// scheme (e.g., "/var/log/foo.log") are treated as local file paths. Without
// a scheme, the special paths "stdout" and "stderr" are interpreted as
// os.Stdout and os.Stderr. When specified without a scheme, relative file
// paths also work.
func Open(paths ...string) (zapcore.WriteSyncer, func(), error) { func Open(paths ...string) (zapcore.WriteSyncer, func(), error) {
writers, close, err := open(paths) writers, close, err := open(paths)
if err != nil { if err != nil {
@ -47,33 +59,24 @@ func Open(paths ...string) (zapcore.WriteSyncer, func(), error) {
} }
func open(paths []string) ([]zapcore.WriteSyncer, func(), error) { func open(paths []string) ([]zapcore.WriteSyncer, func(), error) {
var openErr error
writers := make([]zapcore.WriteSyncer, 0, len(paths)) writers := make([]zapcore.WriteSyncer, 0, len(paths))
files := make([]*os.File, 0, len(paths)) closers := make([]io.Closer, 0, len(paths))
close := func() { close := func() {
for _, f := range files { for _, c := range closers {
f.Close() c.Close()
}
}
for _, path := range paths {
switch path {
case "stdout":
writers = append(writers, os.Stdout)
// Don't close standard out.
continue
case "stderr":
writers = append(writers, os.Stderr)
// Don't close standard error.
continue
}
f, err := os.OpenFile(path, os.O_WRONLY|os.O_APPEND|os.O_CREATE, 0644)
openErr = multierr.Append(openErr, err)
if err == nil {
writers = append(writers, f)
files = append(files, f)
} }
} }
var openErr error
for _, path := range paths {
sink, err := newSink(path)
if err != nil {
openErr = multierr.Append(openErr, fmt.Errorf("couldn't open sink %q: %v", path, err))
continue
}
writers = append(writers, sink)
closers = append(closers, sink)
}
if openErr != nil { if openErr != nil {
close() close()
return writers, nil, openErr return writers, nil, openErr

View File

@ -44,10 +44,15 @@ func getJSONEncoder() *jsonEncoder {
} }
func putJSONEncoder(enc *jsonEncoder) { func putJSONEncoder(enc *jsonEncoder) {
if enc.reflectBuf != nil {
enc.reflectBuf.Free()
}
enc.EncoderConfig = nil enc.EncoderConfig = nil
enc.buf = nil enc.buf = nil
enc.spaced = false enc.spaced = false
enc.openNamespaces = 0 enc.openNamespaces = 0
enc.reflectBuf = nil
enc.reflectEnc = nil
_jsonPool.Put(enc) _jsonPool.Put(enc)
} }
@ -56,6 +61,10 @@ type jsonEncoder struct {
buf *buffer.Buffer buf *buffer.Buffer
spaced bool // include spaces after colons and commas spaced bool // include spaces after colons and commas
openNamespaces int openNamespaces int
// for encoding generic values by reflection
reflectBuf *buffer.Buffer
reflectEnc *json.Encoder
} }
// NewJSONEncoder creates a fast, low-allocation JSON encoder. The encoder // NewJSONEncoder creates a fast, low-allocation JSON encoder. The encoder
@ -124,13 +133,24 @@ func (enc *jsonEncoder) AddInt64(key string, val int64) {
enc.AppendInt64(val) enc.AppendInt64(val)
} }
func (enc *jsonEncoder) resetReflectBuf() {
if enc.reflectBuf == nil {
enc.reflectBuf = bufferpool.Get()
enc.reflectEnc = json.NewEncoder(enc.reflectBuf)
} else {
enc.reflectBuf.Reset()
}
}
func (enc *jsonEncoder) AddReflected(key string, obj interface{}) error { func (enc *jsonEncoder) AddReflected(key string, obj interface{}) error {
marshaled, err := json.Marshal(obj) enc.resetReflectBuf()
err := enc.reflectEnc.Encode(obj)
if err != nil { if err != nil {
return err return err
} }
enc.reflectBuf.TrimNewline()
enc.addKey(key) enc.addKey(key)
_, err = enc.buf.Write(marshaled) _, err = enc.buf.Write(enc.reflectBuf.Bytes())
return err return err
} }
@ -213,12 +233,14 @@ func (enc *jsonEncoder) AppendInt64(val int64) {
} }
func (enc *jsonEncoder) AppendReflected(val interface{}) error { func (enc *jsonEncoder) AppendReflected(val interface{}) error {
marshaled, err := json.Marshal(val) enc.resetReflectBuf()
err := enc.reflectEnc.Encode(val)
if err != nil { if err != nil {
return err return err
} }
enc.reflectBuf.TrimNewline()
enc.addElementSeparator() enc.addElementSeparator()
_, err = enc.buf.Write(marshaled) _, err = enc.buf.Write(enc.reflectBuf.Bytes())
return err return err
} }

View File

@ -43,7 +43,7 @@ func NewMapObjectEncoder() *MapObjectEncoder {
// AddArray implements ObjectEncoder. // AddArray implements ObjectEncoder.
func (m *MapObjectEncoder) AddArray(key string, v ArrayMarshaler) error { func (m *MapObjectEncoder) AddArray(key string, v ArrayMarshaler) error {
arr := &sliceArrayEncoder{} arr := &sliceArrayEncoder{elems: make([]interface{}, 0)}
err := v.MarshalLogArray(arr) err := v.MarshalLogArray(arr)
m.cur[key] = arr.elems m.cur[key] = arr.elems
return err return err