mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-01-05 19:59:37 -06:00
Bump github.com/rs/zerolog from 1.29.1 to 1.30.0
Bumps [github.com/rs/zerolog](https://github.com/rs/zerolog) from 1.29.1 to 1.30.0. - [Release notes](https://github.com/rs/zerolog/releases) - [Commits](https://github.com/rs/zerolog/compare/v1.29.1...v1.30.0) --- updated-dependencies: - dependency-name: github.com/rs/zerolog dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com>
This commit is contained in:
committed by
Ralf Haferkamp
parent
a2f02d8a89
commit
5f8750cfac
4
go.mod
4
go.mod
@@ -69,7 +69,7 @@ require (
|
||||
github.com/r3labs/sse/v2 v2.10.0
|
||||
github.com/riandyrn/otelchi v0.5.1
|
||||
github.com/rogpeppe/go-internal v1.11.0
|
||||
github.com/rs/zerolog v1.29.1
|
||||
github.com/rs/zerolog v1.30.0
|
||||
github.com/shamaton/msgpack/v2 v2.1.1
|
||||
github.com/sirupsen/logrus v1.9.3
|
||||
github.com/spf13/cobra v1.7.0
|
||||
@@ -284,7 +284,7 @@ require (
|
||||
github.com/rcrowley/go-metrics v0.0.0-20200313005456-10cdbea86bc0 // indirect
|
||||
github.com/rivo/uniseg v0.4.2 // indirect
|
||||
github.com/rs/cors v1.9.0 // indirect
|
||||
github.com/rs/xid v1.4.0 // indirect
|
||||
github.com/rs/xid v1.5.0 // indirect
|
||||
github.com/russellhaering/goxmldsig v1.4.0 // indirect
|
||||
github.com/russross/blackfriday/v2 v2.1.0 // indirect
|
||||
github.com/sciencemesh/meshdirectory-web v1.0.4 // indirect
|
||||
|
||||
8
go.sum
8
go.sum
@@ -1790,10 +1790,10 @@ github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUz
|
||||
github.com/rs/cors v1.8.2/go.mod h1:XyqrcTp5zjWr1wsJ8PIRZssZ8b/WMcMf71DJnit4EMU=
|
||||
github.com/rs/cors v1.9.0 h1:l9HGsTsHJcvW14Nk7J9KFz8bzeAWXn3CG6bgt7LsrAE=
|
||||
github.com/rs/cors v1.9.0/go.mod h1:XyqrcTp5zjWr1wsJ8PIRZssZ8b/WMcMf71DJnit4EMU=
|
||||
github.com/rs/xid v1.4.0 h1:qd7wPTDkN6KQx2VmMBLrpHkiyQwgFXRnkOLacUiaSNY=
|
||||
github.com/rs/xid v1.4.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
|
||||
github.com/rs/zerolog v1.29.1 h1:cO+d60CHkknCbvzEWxP0S9K6KqyTjrCNUy1LdQLCGPc=
|
||||
github.com/rs/zerolog v1.29.1/go.mod h1:Le6ESbR7hc+DP6Lt1THiV8CQSdkkNrd3R0XbEgp3ZBU=
|
||||
github.com/rs/xid v1.5.0 h1:mKX4bl4iPYJtEIxp6CYiUuLQ/8DYMoz0PUdtGgMFRVc=
|
||||
github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
|
||||
github.com/rs/zerolog v1.30.0 h1:SymVODrcRsaRaSInD9yQtKbtWqwsfoPcRff/oRXLj4c=
|
||||
github.com/rs/zerolog v1.30.0/go.mod h1:/tk+P47gFdPXq4QYjvCmT5/Gsug2nagsFWBWhAiSi1w=
|
||||
github.com/russellhaering/goxmldsig v1.2.0/go.mod h1:gM4MDENBQf7M+V824SGfyIUVFWydB7n0KkEubVJl+Tw=
|
||||
github.com/russellhaering/goxmldsig v1.4.0 h1:8UcDh/xGyQiyrW+Fq5t8f+l2DLB1+zlhYzkPUJ7Qhys=
|
||||
github.com/russellhaering/goxmldsig v1.4.0/go.mod h1:gM4MDENBQf7M+V824SGfyIUVFWydB7n0KkEubVJl+Tw=
|
||||
|
||||
5
vendor/github.com/rs/xid/.golangci.yml
generated
vendored
Normal file
5
vendor/github.com/rs/xid/.golangci.yml
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
run:
|
||||
tests: false
|
||||
|
||||
output:
|
||||
sort-results: true
|
||||
3
vendor/github.com/rs/xid/README.md
generated
vendored
3
vendor/github.com/rs/xid/README.md
generated
vendored
@@ -70,6 +70,9 @@ References:
|
||||
- Ruby port by [Valar](https://github.com/valarpirai/): https://github.com/valarpirai/ruby_xid
|
||||
- Java port by [0xShamil](https://github.com/0xShamil/): https://github.com/0xShamil/java-xid
|
||||
- Dart port by [Peter Bwire](https://github.com/pitabwire): https://pub.dev/packages/xid
|
||||
- PostgreSQL port by [Rasmus Holm](https://github.com/crholm): https://github.com/modfin/pg-xid
|
||||
- Swift port by [Uditha Atukorala](https://github.com/uditha-atukorala): https://github.com/uditha-atukorala/swift-xid
|
||||
- C++ port by [Uditha Atukorala](https://github.com/uditha-atukorala): https://github.com/uditha-atukorala/libxid
|
||||
|
||||
## Install
|
||||
|
||||
|
||||
41
vendor/github.com/rs/xid/id.go
generated
vendored
41
vendor/github.com/rs/xid/id.go
generated
vendored
@@ -43,7 +43,7 @@ package xid
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"crypto/md5"
|
||||
"crypto/sha256"
|
||||
"crypto/rand"
|
||||
"database/sql/driver"
|
||||
"encoding/binary"
|
||||
@@ -72,13 +72,11 @@ const (
|
||||
)
|
||||
|
||||
var (
|
||||
// objectIDCounter is atomically incremented when generating a new ObjectId
|
||||
// using NewObjectId() function. It's used as a counter part of an id.
|
||||
// This id is initialized with a random value.
|
||||
// objectIDCounter is atomically incremented when generating a new ObjectId. It's
|
||||
// used as the counter part of an id. This id is initialized with a random value.
|
||||
objectIDCounter = randInt()
|
||||
|
||||
// machineId stores machine id generated once and used in subsequent calls
|
||||
// to NewObjectId function.
|
||||
// machineID is generated once and used in subsequent calls to the New* functions.
|
||||
machineID = readMachineID()
|
||||
|
||||
// pid stores the current process id
|
||||
@@ -107,9 +105,9 @@ func init() {
|
||||
}
|
||||
}
|
||||
|
||||
// readMachineId generates machine id and puts it into the machineId global
|
||||
// variable. If this function fails to get the hostname, it will cause
|
||||
// a runtime error.
|
||||
// readMachineID generates a machine ID, derived from a platform-specific machine ID
|
||||
// value, or else the machine's hostname, or else a randomly-generated number.
|
||||
// It panics if all of these methods fail.
|
||||
func readMachineID() []byte {
|
||||
id := make([]byte, 3)
|
||||
hid, err := readPlatformMachineID()
|
||||
@@ -117,7 +115,7 @@ func readMachineID() []byte {
|
||||
hid, err = os.Hostname()
|
||||
}
|
||||
if err == nil && len(hid) != 0 {
|
||||
hw := md5.New()
|
||||
hw := sha256.New()
|
||||
hw.Write([]byte(hid))
|
||||
copy(id, hw.Sum(nil))
|
||||
} else {
|
||||
@@ -148,7 +146,7 @@ func NewWithTime(t time.Time) ID {
|
||||
var id ID
|
||||
// Timestamp, 4 bytes, big endian
|
||||
binary.BigEndian.PutUint32(id[:], uint32(t.Unix()))
|
||||
// Machine, first 3 bytes of md5(hostname)
|
||||
// Machine ID, 3 bytes
|
||||
id[4] = machineID[0]
|
||||
id[5] = machineID[1]
|
||||
id[6] = machineID[2]
|
||||
@@ -239,6 +237,7 @@ func (id *ID) UnmarshalText(text []byte) error {
|
||||
}
|
||||
}
|
||||
if !decode(id, text) {
|
||||
*id = nilID
|
||||
return ErrInvalidID
|
||||
}
|
||||
return nil
|
||||
@@ -264,6 +263,10 @@ func decode(id *ID, src []byte) bool {
|
||||
_ = id[11]
|
||||
|
||||
id[11] = dec[src[17]]<<6 | dec[src[18]]<<1 | dec[src[19]]>>4
|
||||
// check the last byte
|
||||
if encoding[(id[11]<<4)&0x1F] != src[19] {
|
||||
return false
|
||||
}
|
||||
id[10] = dec[src[16]]<<3 | dec[src[17]]>>2
|
||||
id[9] = dec[src[14]]<<5 | dec[src[15]]
|
||||
id[8] = dec[src[12]]<<7 | dec[src[13]]<<2 | dec[src[14]]>>3
|
||||
@@ -275,16 +278,7 @@ func decode(id *ID, src []byte) bool {
|
||||
id[2] = dec[src[3]]<<4 | dec[src[4]]>>1
|
||||
id[1] = dec[src[1]]<<6 | dec[src[2]]<<1 | dec[src[3]]>>4
|
||||
id[0] = dec[src[0]]<<3 | dec[src[1]]>>2
|
||||
|
||||
// Validate that there are no discarer bits (padding) in src that would
|
||||
// cause the string-encoded id not to equal src.
|
||||
var check [4]byte
|
||||
|
||||
check[3] = encoding[(id[11]<<4)&0x1F]
|
||||
check[2] = encoding[(id[11]>>1)&0x1F]
|
||||
check[1] = encoding[(id[11]>>6)&0x1F|(id[10]<<2)&0x1F]
|
||||
check[0] = encoding[id[10]>>3]
|
||||
return bytes.Equal([]byte(src[16:20]), check[:])
|
||||
return true
|
||||
}
|
||||
|
||||
// Time returns the timestamp part of the id.
|
||||
@@ -344,6 +338,11 @@ func (id ID) IsNil() bool {
|
||||
return id == nilID
|
||||
}
|
||||
|
||||
// Alias of IsNil
|
||||
func (id ID) IsZero() bool {
|
||||
return id.IsNil()
|
||||
}
|
||||
|
||||
// NilID returns a zero value for `xid.ID`.
|
||||
func NilID() ID {
|
||||
return nilID
|
||||
|
||||
74
vendor/github.com/rs/zerolog/README.md
generated
vendored
74
vendor/github.com/rs/zerolog/README.md
generated
vendored
@@ -24,7 +24,7 @@ Find out [who uses zerolog](https://github.com/rs/zerolog/wiki/Who-uses-zerolog)
|
||||
* [Sampling](#log-sampling)
|
||||
* [Hooks](#hooks)
|
||||
* [Contextual fields](#contextual-logging)
|
||||
* `context.Context` integration
|
||||
* [`context.Context` integration](#contextcontext-integration)
|
||||
* [Integration with `net/http`](#integration-with-nethttp)
|
||||
* [JSON and CBOR encoding formats](#binary-encoding)
|
||||
* [Pretty logging for development](#pretty-logging)
|
||||
@@ -499,7 +499,7 @@ log.Ctx(ctx).Info().Msg("hello world")
|
||||
### Set as standard logger output
|
||||
|
||||
```go
|
||||
log := zerolog.New(os.Stdout).With().
|
||||
stdlog := zerolog.New(os.Stdout).With().
|
||||
Str("foo", "bar").
|
||||
Logger()
|
||||
|
||||
@@ -511,6 +511,58 @@ stdlog.Print("hello world")
|
||||
// Output: {"foo":"bar","message":"hello world"}
|
||||
```
|
||||
|
||||
### context.Context integration
|
||||
|
||||
Go contexts are commonly passed throughout Go code, and this can help you pass
|
||||
your Logger into places it might otherwise be hard to inject. The `Logger`
|
||||
instance may be attached to Go context (`context.Context`) using
|
||||
`Logger.WithContext(ctx)` and extracted from it using `zerolog.Ctx(ctx)`.
|
||||
For example:
|
||||
|
||||
```go
|
||||
func f() {
|
||||
logger := zerolog.New(os.Stdout)
|
||||
ctx := context.Background()
|
||||
|
||||
// Attach the Logger to the context.Context
|
||||
ctx = logger.WithContext(ctx)
|
||||
someFunc(ctx)
|
||||
}
|
||||
|
||||
func someFunc(ctx context.Context) {
|
||||
// Get Logger from the go Context. if it's nil, then
|
||||
// `zerolog.DefaultContextLogger` is returned, if
|
||||
// `DefaultContextLogger` is nil, then a disabled logger is returned.
|
||||
logger := zerolog.Ctx(ctx)
|
||||
logger.Info().Msg("Hello")
|
||||
}
|
||||
```
|
||||
|
||||
A second form of `context.Context` integration allows you to pass the current
|
||||
context.Context into the logged event, and retrieve it from hooks. This can be
|
||||
useful to log trace and span IDs or other information stored in the go context,
|
||||
and facilitates the unification of logging and tracing in some systems:
|
||||
|
||||
```go
|
||||
type TracingHook struct{}
|
||||
|
||||
func (h TracingHook) Run(e *zerolog.Event, level zerolog.Level, msg string) {
|
||||
ctx := e.Ctx()
|
||||
spanId := getSpanIdFromContext(ctx) // as per your tracing framework
|
||||
e.Str("span-id", spanId)
|
||||
}
|
||||
|
||||
func f() {
|
||||
// Setup the logger
|
||||
logger := zerolog.New(os.Stdout)
|
||||
logger = logger.Hook(TracingHook{})
|
||||
|
||||
ctx := context.Background()
|
||||
// Use the Ctx function to make the context available to the hook
|
||||
logger.Info().Ctx(ctx).Msg("Hello")
|
||||
}
|
||||
```
|
||||
|
||||
### Integration with `net/http`
|
||||
|
||||
The `github.com/rs/zerolog/hlog` package provides some helpers to integrate zerolog with `http.Handler`.
|
||||
@@ -703,6 +755,8 @@ Log a static string, without any context or `printf`-style templating:
|
||||
|
||||
## Caveats
|
||||
|
||||
### Field duplication
|
||||
|
||||
Note that zerolog does no de-duplication of fields. Using the same key multiple times creates multiple keys in final JSON:
|
||||
|
||||
```go
|
||||
@@ -714,3 +768,19 @@ logger.Info().
|
||||
```
|
||||
|
||||
In this case, many consumers will take the last value, but this is not guaranteed; check yours if in doubt.
|
||||
|
||||
### Concurrency safety
|
||||
|
||||
Be careful when calling UpdateContext. It is not concurrency safe. Use the With method to create a child logger:
|
||||
|
||||
```go
|
||||
func handler(w http.ResponseWriter, r *http.Request) {
|
||||
// Create a child logger for concurrency safety
|
||||
logger := log.Logger.With().Logger()
|
||||
|
||||
// Add context fields, for example User-Agent from HTTP headers
|
||||
logger.UpdateContext(func(c zerolog.Context) zerolog.Context {
|
||||
...
|
||||
})
|
||||
}
|
||||
```
|
||||
|
||||
13
vendor/github.com/rs/zerolog/context.go
generated
vendored
13
vendor/github.com/rs/zerolog/context.go
generated
vendored
@@ -1,6 +1,7 @@
|
||||
package zerolog
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"math"
|
||||
@@ -165,6 +166,15 @@ func (c Context) Err(err error) Context {
|
||||
return c.AnErr(ErrorFieldName, err)
|
||||
}
|
||||
|
||||
// Ctx adds the context.Context to the logger context. The context.Context is
|
||||
// not rendered in the error message, but is made available for hooks to use.
|
||||
// A typical use case is to extract tracing information from the
|
||||
// context.Context.
|
||||
func (c Context) Ctx(ctx context.Context) Context {
|
||||
c.l.ctx = ctx
|
||||
return c
|
||||
}
|
||||
|
||||
// Bool adds the field key with val as a bool to the logger context.
|
||||
func (c Context) Bool(key string, b bool) Context {
|
||||
c.l.context = enc.AppendBool(enc.AppendKey(c.l.context, key), b)
|
||||
@@ -329,8 +339,9 @@ func (ts timestampHook) Run(e *Event, level Level, msg string) {
|
||||
|
||||
var th = timestampHook{}
|
||||
|
||||
// Timestamp adds the current local time as UNIX timestamp to the logger context with the "time" key.
|
||||
// Timestamp adds the current local time to the logger context with the "time" key, formatted using zerolog.TimeFieldFormat.
|
||||
// To customize the key name, change zerolog.TimestampFieldName.
|
||||
// To customize the time format, change zerolog.TimeFieldFormat.
|
||||
//
|
||||
// NOTE: It won't dedupe the "time" key if the *Context has one already.
|
||||
func (c Context) Timestamp() Context {
|
||||
|
||||
3
vendor/github.com/rs/zerolog/encoder_cbor.go
generated
vendored
3
vendor/github.com/rs/zerolog/encoder_cbor.go
generated
vendored
@@ -24,6 +24,9 @@ func init() {
|
||||
func appendJSON(dst []byte, j []byte) []byte {
|
||||
return cbor.AppendEmbeddedJSON(dst, j)
|
||||
}
|
||||
func appendCBOR(dst []byte, c []byte) []byte {
|
||||
return cbor.AppendEmbeddedCBOR(dst, c)
|
||||
}
|
||||
|
||||
// decodeIfBinaryToString - converts a binary formatted log msg to a
|
||||
// JSON formatted String Log message.
|
||||
|
||||
12
vendor/github.com/rs/zerolog/encoder_json.go
generated
vendored
12
vendor/github.com/rs/zerolog/encoder_json.go
generated
vendored
@@ -6,6 +6,7 @@ package zerolog
|
||||
// JSON encoded byte stream.
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"github.com/rs/zerolog/internal/json"
|
||||
)
|
||||
|
||||
@@ -25,6 +26,17 @@ func init() {
|
||||
func appendJSON(dst []byte, j []byte) []byte {
|
||||
return append(dst, j...)
|
||||
}
|
||||
func appendCBOR(dst []byte, cbor []byte) []byte {
|
||||
dst = append(dst, []byte("\"data:application/cbor;base64,")...)
|
||||
l := len(dst)
|
||||
enc := base64.StdEncoding
|
||||
n := enc.EncodedLen(len(cbor))
|
||||
for i := 0; i < n; i++ {
|
||||
dst = append(dst, '.')
|
||||
}
|
||||
enc.Encode(dst[l:], cbor)
|
||||
return append(dst, '"')
|
||||
}
|
||||
|
||||
func decodeIfBinaryToString(in []byte) string {
|
||||
return string(in)
|
||||
|
||||
42
vendor/github.com/rs/zerolog/event.go
generated
vendored
42
vendor/github.com/rs/zerolog/event.go
generated
vendored
@@ -1,6 +1,7 @@
|
||||
package zerolog
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net"
|
||||
"os"
|
||||
@@ -24,9 +25,10 @@ type Event struct {
|
||||
w LevelWriter
|
||||
level Level
|
||||
done func(msg string)
|
||||
stack bool // enable error stack trace
|
||||
ch []Hook // hooks from context
|
||||
skipFrame int // The number of additional frames to skip when printing the caller.
|
||||
stack bool // enable error stack trace
|
||||
ch []Hook // hooks from context
|
||||
skipFrame int // The number of additional frames to skip when printing the caller.
|
||||
ctx context.Context // Optional Go context for event
|
||||
}
|
||||
|
||||
func putEvent(e *Event) {
|
||||
@@ -318,6 +320,18 @@ func (e *Event) RawJSON(key string, b []byte) *Event {
|
||||
return e
|
||||
}
|
||||
|
||||
// RawCBOR adds already encoded CBOR to the log line under key.
|
||||
//
|
||||
// No sanity check is performed on b
|
||||
// Note: The full featureset of CBOR is supported as data will not be mapped to json but stored as data-url
|
||||
func (e *Event) RawCBOR(key string, b []byte) *Event {
|
||||
if e == nil {
|
||||
return e
|
||||
}
|
||||
e.buf = appendCBOR(enc.AppendKey(e.buf, key), b)
|
||||
return e
|
||||
}
|
||||
|
||||
// AnErr adds the field key with serialized err to the *Event context.
|
||||
// If err is nil, no field is added.
|
||||
func (e *Event) AnErr(key string, err error) *Event {
|
||||
@@ -405,6 +419,28 @@ func (e *Event) Stack() *Event {
|
||||
return e
|
||||
}
|
||||
|
||||
// Ctx adds the Go Context to the *Event context. The context is not rendered
|
||||
// in the output message, but is available to hooks and to Func() calls via the
|
||||
// GetCtx() accessor. A typical use case is to extract tracing information from
|
||||
// the Go Ctx.
|
||||
func (e *Event) Ctx(ctx context.Context) *Event {
|
||||
if e != nil {
|
||||
e.ctx = ctx
|
||||
}
|
||||
return e
|
||||
}
|
||||
|
||||
// GetCtx retrieves the Go context.Context which is optionally stored in the
|
||||
// Event. This allows Hooks and functions passed to Func() to retrieve values
|
||||
// which are stored in the context.Context. This can be useful in tracing,
|
||||
// where span information is commonly propagated in the context.Context.
|
||||
func (e *Event) GetCtx() context.Context {
|
||||
if e == nil || e.ctx == nil {
|
||||
return context.Background()
|
||||
}
|
||||
return e.ctx
|
||||
}
|
||||
|
||||
// Bool adds the field key with val as a bool to the *Event context.
|
||||
func (e *Event) Bool(key string, b bool) *Event {
|
||||
if e == nil {
|
||||
|
||||
3
vendor/github.com/rs/zerolog/internal/cbor/cbor.go
generated
vendored
3
vendor/github.com/rs/zerolog/internal/cbor/cbor.go
generated
vendored
@@ -26,7 +26,8 @@ const (
|
||||
additionalTypeBreak byte = 31
|
||||
|
||||
// Tag Sub-types.
|
||||
additionalTypeTimestamp byte = 01
|
||||
additionalTypeTimestamp byte = 01
|
||||
additionalTypeEmbeddedCBOR byte = 63
|
||||
|
||||
// Extended Tags - from https://www.iana.org/assignments/cbor-tags/cbor-tags.xhtml
|
||||
additionalTypeTagNetworkAddr uint16 = 260
|
||||
|
||||
40
vendor/github.com/rs/zerolog/internal/cbor/decode_stream.go
generated
vendored
40
vendor/github.com/rs/zerolog/internal/cbor/decode_stream.go
generated
vendored
@@ -5,6 +5,7 @@ package cbor
|
||||
import (
|
||||
"bufio"
|
||||
"bytes"
|
||||
"encoding/base64"
|
||||
"fmt"
|
||||
"io"
|
||||
"math"
|
||||
@@ -213,6 +214,31 @@ func decodeString(src *bufio.Reader, noQuotes bool) []byte {
|
||||
}
|
||||
return append(result, '"')
|
||||
}
|
||||
func decodeStringToDataUrl(src *bufio.Reader, mimeType string) []byte {
|
||||
pb := readByte(src)
|
||||
major := pb & maskOutAdditionalType
|
||||
minor := pb & maskOutMajorType
|
||||
if major != majorTypeByteString {
|
||||
panic(fmt.Errorf("Major type is: %d in decodeString", major))
|
||||
}
|
||||
length := decodeIntAdditionalType(src, minor)
|
||||
l := int(length)
|
||||
enc := base64.StdEncoding
|
||||
lEnc := enc.EncodedLen(l)
|
||||
result := make([]byte, len("\"data:;base64,\"")+len(mimeType)+lEnc)
|
||||
dest := result
|
||||
u := copy(dest, "\"data:")
|
||||
dest = dest[u:]
|
||||
u = copy(dest, mimeType)
|
||||
dest = dest[u:]
|
||||
u = copy(dest, ";base64,")
|
||||
dest = dest[u:]
|
||||
pbs := readNBytes(src, l)
|
||||
enc.Encode(dest, pbs)
|
||||
dest = dest[lEnc:]
|
||||
dest[0] = '"'
|
||||
return result
|
||||
}
|
||||
|
||||
func decodeUTF8String(src *bufio.Reader) []byte {
|
||||
pb := readByte(src)
|
||||
@@ -349,6 +375,20 @@ func decodeTagData(src *bufio.Reader) []byte {
|
||||
switch minor {
|
||||
case additionalTypeTimestamp:
|
||||
return decodeTimeStamp(src)
|
||||
case additionalTypeIntUint8:
|
||||
val := decodeIntAdditionalType(src, minor)
|
||||
switch byte(val) {
|
||||
case additionalTypeEmbeddedCBOR:
|
||||
pb := readByte(src)
|
||||
dataMajor := pb & maskOutAdditionalType
|
||||
if dataMajor != majorTypeByteString {
|
||||
panic(fmt.Errorf("Unsupported embedded Type: %d in decodeEmbeddedCBOR", dataMajor))
|
||||
}
|
||||
src.UnreadByte()
|
||||
return decodeStringToDataUrl(src, "application/cbor")
|
||||
default:
|
||||
panic(fmt.Errorf("Unsupported Additional Tag Type: %d in decodeTagData", val))
|
||||
}
|
||||
|
||||
// Tag value is larger than 256 (so uint16).
|
||||
case additionalTypeIntUint16:
|
||||
|
||||
22
vendor/github.com/rs/zerolog/internal/cbor/string.go
generated
vendored
22
vendor/github.com/rs/zerolog/internal/cbor/string.go
generated
vendored
@@ -93,3 +93,25 @@ func AppendEmbeddedJSON(dst, s []byte) []byte {
|
||||
}
|
||||
return append(dst, s...)
|
||||
}
|
||||
|
||||
// AppendEmbeddedCBOR adds a tag and embeds input CBOR as such.
|
||||
func AppendEmbeddedCBOR(dst, s []byte) []byte {
|
||||
major := majorTypeTags
|
||||
minor := additionalTypeEmbeddedCBOR
|
||||
|
||||
// Append the TAG to indicate this is Embedded JSON.
|
||||
dst = append(dst, major|additionalTypeIntUint8)
|
||||
dst = append(dst, minor)
|
||||
|
||||
// Append the CBOR Object as Byte String.
|
||||
major = majorTypeByteString
|
||||
|
||||
l := len(s)
|
||||
if l <= additionalMax {
|
||||
lb := byte(l)
|
||||
dst = append(dst, major|lb)
|
||||
} else {
|
||||
dst = appendCborTypePrefix(dst, major, uint64(l))
|
||||
}
|
||||
return append(dst, s...)
|
||||
}
|
||||
|
||||
27
vendor/github.com/rs/zerolog/log.go
generated
vendored
27
vendor/github.com/rs/zerolog/log.go
generated
vendored
@@ -82,8 +82,9 @@
|
||||
// log.Warn().Msg("")
|
||||
// // Output: {"level":"warn","severity":"warn"}
|
||||
//
|
||||
// # Caveats
|
||||
//
|
||||
// Caveats
|
||||
// Field duplication:
|
||||
//
|
||||
// There is no fields deduplication out-of-the-box.
|
||||
// Using the same key multiple times creates new key in final JSON each time.
|
||||
@@ -96,9 +97,24 @@
|
||||
//
|
||||
// In this case, many consumers will take the last value,
|
||||
// but this is not guaranteed; check yours if in doubt.
|
||||
//
|
||||
// Concurrency safety:
|
||||
//
|
||||
// Be careful when calling UpdateContext. It is not concurrency safe. Use the With method to create a child logger:
|
||||
//
|
||||
// func handler(w http.ResponseWriter, r *http.Request) {
|
||||
// // Create a child logger for concurrency safety
|
||||
// logger := log.Logger.With().Logger()
|
||||
//
|
||||
// // Add context fields, for example User-Agent from HTTP headers
|
||||
// logger.UpdateContext(func(c zerolog.Context) zerolog.Context {
|
||||
// ...
|
||||
// })
|
||||
// }
|
||||
package zerolog
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
@@ -218,6 +234,7 @@ type Logger struct {
|
||||
context []byte
|
||||
hooks []Hook
|
||||
stack bool
|
||||
ctx context.Context
|
||||
}
|
||||
|
||||
// New creates a root logger with given output writer. If the output writer implements
|
||||
@@ -275,7 +292,8 @@ func (l Logger) With() Context {
|
||||
|
||||
// UpdateContext updates the internal logger's context.
|
||||
//
|
||||
// Use this method with caution. If unsure, prefer the With method.
|
||||
// Caution: This method is not concurrency safe.
|
||||
// Use the With method to create a child logger before modifying the context from concurrent goroutines.
|
||||
func (l *Logger) UpdateContext(update func(c Context) Context) {
|
||||
if l == disabledLogger {
|
||||
return
|
||||
@@ -309,7 +327,9 @@ func (l Logger) Sample(s Sampler) Logger {
|
||||
|
||||
// Hook returns a logger with the h Hook.
|
||||
func (l Logger) Hook(h Hook) Logger {
|
||||
l.hooks = append(l.hooks, h)
|
||||
newHooks := make([]Hook, len(l.hooks), len(l.hooks)+1)
|
||||
copy(newHooks, l.hooks)
|
||||
l.hooks = append(newHooks, h)
|
||||
return l
|
||||
}
|
||||
|
||||
@@ -453,6 +473,7 @@ func (l *Logger) newEvent(level Level, done func(string)) *Event {
|
||||
e := newEvent(l.w, level)
|
||||
e.done = done
|
||||
e.ch = l.hooks
|
||||
e.ctx = l.ctx
|
||||
if level != NoLevel && LevelFieldName != "" {
|
||||
e.Str(LevelFieldName, LevelFieldMarshalFunc(level))
|
||||
}
|
||||
|
||||
23
vendor/github.com/rs/zerolog/pkgerrors/stacktrace.go
generated
vendored
23
vendor/github.com/rs/zerolog/pkgerrors/stacktrace.go
generated
vendored
@@ -42,15 +42,32 @@ func frameField(f errors.Frame, s *state, c rune) string {
|
||||
|
||||
// MarshalStack implements pkg/errors stack trace marshaling.
|
||||
//
|
||||
// zerolog.ErrorStackMarshaler = MarshalStack
|
||||
// zerolog.ErrorStackMarshaler = MarshalStack
|
||||
func MarshalStack(err error) interface{} {
|
||||
type stackTracer interface {
|
||||
StackTrace() errors.StackTrace
|
||||
}
|
||||
sterr, ok := err.(stackTracer)
|
||||
if !ok {
|
||||
var sterr stackTracer
|
||||
var ok bool
|
||||
for err != nil {
|
||||
sterr, ok = err.(stackTracer)
|
||||
if ok {
|
||||
break
|
||||
}
|
||||
|
||||
u, ok := err.(interface {
|
||||
Unwrap() error
|
||||
})
|
||||
if !ok {
|
||||
return nil
|
||||
}
|
||||
|
||||
err = u.Unwrap()
|
||||
}
|
||||
if sterr == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
st := sterr.StackTrace()
|
||||
s := &state{}
|
||||
out := make([]map[string]string, 0, len(st))
|
||||
|
||||
4
vendor/modules.txt
vendored
4
vendor/modules.txt
vendored
@@ -1580,10 +1580,10 @@ github.com/rogpeppe/go-internal/lockedfile/internal/filelock
|
||||
# github.com/rs/cors v1.9.0
|
||||
## explicit; go 1.13
|
||||
github.com/rs/cors
|
||||
# github.com/rs/xid v1.4.0
|
||||
# github.com/rs/xid v1.5.0
|
||||
## explicit; go 1.12
|
||||
github.com/rs/xid
|
||||
# github.com/rs/zerolog v1.29.1
|
||||
# github.com/rs/zerolog v1.30.0
|
||||
## explicit; go 1.15
|
||||
github.com/rs/zerolog
|
||||
github.com/rs/zerolog/internal/cbor
|
||||
|
||||
Reference in New Issue
Block a user