From 3cd7c6ceff5b61ed9c169e68cfefa6a53c5c60e5 Mon Sep 17 00:00:00 2001 From: Prashant Varanasi Date: Fri, 22 Sep 2017 15:58:43 -0700 Subject: [PATCH 1/3] MapEncoder: Store strings in map when AddByteString is used Fixes 503 --- zapcore/field_test.go | 2 +- zapcore/memory_encoder.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/zapcore/field_test.go b/zapcore/field_test.go index 2d8a45f9e..fb722b4b7 100644 --- a/zapcore/field_test.go +++ b/zapcore/field_test.go @@ -95,7 +95,7 @@ func TestFields(t *testing.T) { {t: ObjectMarshalerType, iface: users(2), want: map[string]interface{}{"users": 2}}, {t: BinaryType, iface: []byte("foo"), want: []byte("foo")}, {t: BoolType, i: 0, want: false}, - {t: ByteStringType, iface: []byte("foo"), want: []byte("foo")}, + {t: ByteStringType, iface: []byte("foo"), want: "foo"}, {t: Complex128Type, iface: 1 + 2i, want: 1 + 2i}, {t: Complex64Type, iface: complex64(1 + 2i), want: complex64(1 + 2i)}, {t: DurationType, i: 1000, want: time.Microsecond}, diff --git a/zapcore/memory_encoder.go b/zapcore/memory_encoder.go index 4805c8a94..5c46bc13d 100644 --- a/zapcore/memory_encoder.go +++ b/zapcore/memory_encoder.go @@ -60,7 +60,7 @@ func (m *MapObjectEncoder) AddObject(k string, v ObjectMarshaler) error { func (m *MapObjectEncoder) AddBinary(k string, v []byte) { m.cur[k] = v } // AddByteString implements ObjectEncoder. -func (m *MapObjectEncoder) AddByteString(k string, v []byte) { m.cur[k] = v } +func (m *MapObjectEncoder) AddByteString(k string, v []byte) { m.cur[k] = string(v) } // AddBool implements ObjectEncoder. func (m *MapObjectEncoder) AddBool(k string, v bool) { m.cur[k] = v } From f6c21bfa3f3c18333c7b7b89773bcd92d6189e61 Mon Sep 17 00:00:00 2001 From: Prashant Varanasi Date: Mon, 25 Sep 2017 11:08:46 -0700 Subject: [PATCH 2/3] Add CHANGELOG entry --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 886231c8d..5811202f4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## v1.7.1 (25 Sep 2017) + +Bugfixes: +* [#504][]: Store strings when using AddByteString with the map encoder. + ## v1.7.0 (21 Sep 2017) Enhancements: @@ -261,3 +266,4 @@ upgrade to the upcoming stable release. [#490]: https://github.com/uber-go/zap/pull/490 [#491]: https://github.com/uber-go/zap/pull/491 [#491]: https://github.com/uber-go/zap/pull/439 +[#504]: https://github.com/uber-go/zap/pull/504 From 089228e0cc73d6d8563321a920a491a5af2fd115 Mon Sep 17 00:00:00 2001 From: Prashant Varanasi Date: Mon, 25 Sep 2017 11:14:28 -0700 Subject: [PATCH 3/3] Fix changelog entry for 1.7.0 --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5811202f4..6a1609a21 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,7 @@ Bugfixes: Enhancements: -* [#439][]: Add `NewStdLogAt`, which extends `NewStdLog` by allowing the user +* [#487][]: Add `NewStdLogAt`, which extends `NewStdLog` by allowing the user to specify the level of the logged messages. ## v1.6.0 (30 Aug 2017) @@ -263,6 +263,7 @@ upgrade to the upcoming stable release. [#465]: https://github.com/uber-go/zap/pull/465 [#460]: https://github.com/uber-go/zap/pull/460 [#470]: https://github.com/uber-go/zap/pull/470 +[#487]: https://github.com/uber-go/zap/pull/487 [#490]: https://github.com/uber-go/zap/pull/490 [#491]: https://github.com/uber-go/zap/pull/491 [#491]: https://github.com/uber-go/zap/pull/439