From d7310ed1df9cd662d53f0b50643384921e7f3440 Mon Sep 17 00:00:00 2001 From: andrey1s Date: Sat, 12 Mar 2022 10:01:11 +0300 Subject: [PATCH 1/2] add test append fields --- field/fields_test.go | 15 +++++++++++++++ go.mod | 4 ++++ go.sum | 3 +++ 3 files changed, 22 insertions(+) create mode 100644 field/fields_test.go diff --git a/field/fields_test.go b/field/fields_test.go new file mode 100644 index 0000000..6e7a00f --- /dev/null +++ b/field/fields_test.go @@ -0,0 +1,15 @@ +package field_test + +import ( + "testing" + + "github.com/stretchr/testify/require" + "gitoa.ru/go-4devs/log/field" +) + +func TestFields_Append(t *testing.T) { + fields := field.Fields{field.Any("any", "value")} + fields = fields.Append(field.String("string", "value")) + + require.Len(t, fields, 2) +} diff --git a/go.mod b/go.mod index 3dda211..1ead549 100644 --- a/go.mod +++ b/go.mod @@ -4,6 +4,7 @@ go 1.17 require ( github.com/sirupsen/logrus v1.8.1 + github.com/stretchr/testify v1.7.0 go.opentelemetry.io/otel v0.20.0 go.opentelemetry.io/otel/sdk v0.20.0 go.opentelemetry.io/otel/trace v0.20.0 @@ -11,8 +12,11 @@ require ( ) require ( + github.com/davecgh/go-spew v1.1.1 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect go.opentelemetry.io/otel/metric v0.20.0 // indirect go.uber.org/atomic v1.7.0 // indirect go.uber.org/multierr v1.6.0 // indirect golang.org/x/sys v0.0.0-20210510120138-977fb7262007 // indirect + gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect ) diff --git a/go.sum b/go.sum index a7bb6c2..6dd3b34 100644 --- a/go.sum +++ b/go.sum @@ -5,8 +5,10 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= @@ -67,6 +69,7 @@ golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8T golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -- 2.30.2 From 21c14e24be0c35503ea9a066a268029f7d62daf1 Mon Sep 17 00:00:00 2001 From: andrey1s Date: Sat, 12 Mar 2022 20:00:01 +0300 Subject: [PATCH 2/2] update go version --- .drone.yml | 2 +- go.mod | 2 +- go.sum | 3 +++ logger_example_test.go | 10 +++++----- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/.drone.yml b/.drone.yml index 886aa50..81d9f14 100644 --- a/.drone.yml +++ b/.drone.yml @@ -3,7 +3,7 @@ name: default steps: - name: test - image: golang:1.17.1 + image: golang:1.17.6 volumes: - name: deps path: /go/src/mod diff --git a/go.mod b/go.mod index 1ead549..14730db 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ require ( go.opentelemetry.io/otel v0.20.0 go.opentelemetry.io/otel/sdk v0.20.0 go.opentelemetry.io/otel/trace v0.20.0 - go.uber.org/zap v1.19.1 + go.uber.org/zap v1.21.0 ) require ( diff --git a/go.sum b/go.sum index 6dd3b34..c99ccf0 100644 --- a/go.sum +++ b/go.sum @@ -36,10 +36,13 @@ go.uber.org/atomic v1.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw= go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/goleak v1.1.11-0.20210813005559-691160354723 h1:sHOAIxRGBp443oHZIPB+HsUGaksVCXVQENPxwTfQdH4= go.uber.org/goleak v1.1.11-0.20210813005559-691160354723/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ= +go.uber.org/goleak v1.1.11/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ= go.uber.org/multierr v1.6.0 h1:y6IPFStTAIT5Ytl7/XYmHvzXQ7S3g/IeZW9hyZ5thw4= go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= go.uber.org/zap v1.19.1 h1:ue41HOKd1vGURxrmeKIgELGb3jPW9DMUDGtsinblHwI= go.uber.org/zap v1.19.1/go.mod h1:j3DNczoxDZroyBnOT1L/Q79cfUMGZxlv/9dzN7SM1rI= +go.uber.org/zap v1.21.0 h1:WefMeulhovoZ2sYXz7st6K0sLj7bBhpiFaud4r4zST8= +go.uber.org/zap v1.21.0/go.mod h1:wjWOCqI0f2ZZrJF/UufIOkiC8ii6tm1iqIsLo76RfJw= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= diff --git a/logger_example_test.go b/logger_example_test.go index cfa8d2a..d36b4c4 100644 --- a/logger_example_test.go +++ b/logger_example_test.go @@ -66,7 +66,7 @@ func ExampleNew_jsonFormat() { log.GoVersion("go-version"), ) logger.Err(ctx, "same error message") - // Output: {"go-version":"go1.17.1","level":"error","msg":"same error message"} + // Output: {"go-version":"go1.17.6","level":"error","msg":"same error message"} } func ExampleNew_textEncoding() { @@ -79,8 +79,8 @@ func ExampleNew_textEncoding() { logger.InfoKVs(ctx, "same info message", "api-version", 0.1) // Output: - // msg="same error message" level=error go-version=go1.17.1 - // msg="same info message" api-version=0.1 level=info go-version=go1.17.1 + // msg="same error message" level=error go-version=go1.17.6 + // msg="same info message" api-version=0.1 level=info go-version=go1.17.6 } type ctxKey string @@ -102,7 +102,7 @@ func ExampleWith() { levelInfo, log.WithContextValue(requestID), log.KeyValue("api", "0.1.0"), log.GoVersion("go"), ) logger.Info(vctx, "same message") - // Output: msg="same message" level=info requestID=6a5fa048-7181-11ea-bc55-0242ac130003 api=0.1.0 go=go1.17.1 + // Output: msg="same message" level=info requestID=6a5fa048-7181-11ea-bc55-0242ac130003 api=0.1.0 go=go1.17.6 } func ExampleLogger_Print() { @@ -111,7 +111,7 @@ func ExampleLogger_Print() { levelInfo, log.KeyValue("client", "http"), log.KeyValue("api", "0.1.0"), log.GoVersion("go"), ) logger.Print("same message") - // Output: msg="same message" level=info client=http api=0.1.0 go=go1.17.1 + // Output: msg="same message" level=info client=http api=0.1.0 go=go1.17.6 } func ExamplePrint() { -- 2.30.2