From a7b57a35a4b1046fa83f3084f5673943bacb1551 Mon Sep 17 00:00:00 2001 From: Minho Park Date: Mon, 6 Aug 2018 13:36:06 -0700 Subject: [PATCH] Revert "Support fast Zap logging (#361)" This reverts commit 19af15f5ba56daf51e88b41aaab85f0df1292b46. --- .travis.yml | 2 + CHANGELOG.md | 4 +- envelope/internal/tests/enums/types.go | 133 ---- envelope/internal/tests/exceptions/types.go | 19 - .../internal/tests/services/cache_clear.go | 8 - .../tests/services/cache_clearafter.go | 11 - .../services/conflictingnames_setvalue.go | 20 - .../tests/services/keyvalue_deletevalue.go | 28 - .../tests/services/keyvalue_getmanyvalues.go | 54 -- .../tests/services/keyvalue_getvalue.go | 28 - .../tests/services/keyvalue_setvalue.go | 23 - .../tests/services/keyvalue_setvaluev2.go | 20 - .../internal/tests/services/keyvalue_size.go | 18 - ...service_name_non_standard_function_name.go | 15 - envelope/internal/tests/services/types.go | 21 - envelope/internal/tests/structs/types.go | 265 ------- envelope/internal/tests/typedefs/types.go | 190 ----- envelope/internal/tests/unions/types.go | 74 -- gen/enum.go | 17 - gen/field.go | 46 +- gen/generator.go | 5 - gen/internal/tests/collision/types.go | 172 ----- gen/internal/tests/containers/types.go | 709 ------------------ gen/internal/tests/enum_conflict/types.go | 31 - gen/internal/tests/enums/types.go | 133 ---- gen/internal/tests/exceptions/types.go | 19 - gen/internal/tests/services/cache_clear.go | 8 - .../tests/services/cache_clearafter.go | 11 - .../services/conflictingnames_setvalue.go | 20 - .../tests/services/keyvalue_deletevalue.go | 28 - .../tests/services/keyvalue_getmanyvalues.go | 54 -- .../tests/services/keyvalue_getvalue.go | 28 - .../tests/services/keyvalue_setvalue.go | 23 - .../tests/services/keyvalue_setvaluev2.go | 19 - gen/internal/tests/services/keyvalue_size.go | 18 - ...service_name_non_standard_function_name.go | 15 - gen/internal/tests/services/types.go | 21 - gen/internal/tests/structs/types.go | 260 ------- gen/internal/tests/typedefs/types.go | 189 ----- gen/internal/tests/unions/types.go | 74 -- gen/internal/tests/uuid_conflict/types.go | 12 - gen/list.go | 48 +- gen/map.go | 141 ---- gen/set.go | 52 +- gen/type.go | 4 - gen/typedef.go | 20 - gen/zap.go | 132 ---- gen/zap_test.go | 532 ------------- glide.lock | 34 +- glide.yaml | 2 - internal/envelope/exception/types.go | 47 -- plugin/api/plugin_goodbye.go | 15 - plugin/api/plugin_handshake.go | 25 - plugin/api/servicegenerator_generate.go | 25 - plugin/api/types.go | 362 --------- 55 files changed, 17 insertions(+), 4267 deletions(-) delete mode 100644 gen/zap.go delete mode 100644 gen/zap_test.go diff --git a/.travis.yml b/.travis.yml index cc0bdd71..13ed7ff3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,6 +6,8 @@ go_import_path: go.uber.org/thriftrw matrix: include: + - go: 1.7 + - go: 1.8 - go: 1.9 - go: '1.10' env: LINT=1 diff --git a/CHANGELOG.md b/CHANGELOG.md index 0b13a6bb..7a3d0e85 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,9 +5,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). ## [Unreleased] -- Added `zapcore.MarshalLogObject/Array` method to all generated structs - and its underlying components, enums, and non-primitive typedefs, implementing - Zap marshalers. +- No changes yet. ## [1.12.0] - 2018-06-25 ### Added diff --git a/envelope/internal/tests/enums/types.go b/envelope/internal/tests/enums/types.go index a83648a6..76d35ba4 100644 --- a/envelope/internal/tests/enums/types.go +++ b/envelope/internal/tests/enums/types.go @@ -28,7 +28,6 @@ import ( "encoding/json" "fmt" "go.uber.org/thriftrw/wire" - "go.uber.org/zap/zapcore" "math" "strconv" "strings" @@ -55,13 +54,6 @@ func (v EmptyEnum) MarshalText() ([]byte, error) { return []byte(strconv.FormatInt(int64(v), 10)), nil } -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of EmptyEnum. -func (v EmptyEnum) MarshalLogObject(enc zapcore.ObjectEncoder) error { - enc.AddInt32("value", int32(v)) - return nil -} - // Ptr returns a pointer to this enum value. func (v EmptyEnum) Ptr() *EmptyEnum { return &v @@ -208,21 +200,6 @@ func (v EnumDefault) MarshalText() ([]byte, error) { return []byte(strconv.FormatInt(int64(v), 10)), nil } -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of EnumDefault. -func (v EnumDefault) MarshalLogObject(enc zapcore.ObjectEncoder) error { - enc.AddInt32("value", int32(v)) - switch int32(v) { - case 0: - enc.AddString("name", "Foo") - case 1: - enc.AddString("name", "Bar") - case 2: - enc.AddString("name", "Baz") - } - return nil -} - // Ptr returns a pointer to this enum value. func (v EnumDefault) Ptr() *EnumDefault { return &v @@ -427,33 +404,6 @@ func (v EnumWithDuplicateName) MarshalText() ([]byte, error) { return []byte(strconv.FormatInt(int64(v), 10)), nil } -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of EnumWithDuplicateName. -func (v EnumWithDuplicateName) MarshalLogObject(enc zapcore.ObjectEncoder) error { - enc.AddInt32("value", int32(v)) - switch int32(v) { - case 0: - enc.AddString("name", "A") - case 1: - enc.AddString("name", "B") - case 2: - enc.AddString("name", "C") - case 3: - enc.AddString("name", "P") - case 4: - enc.AddString("name", "Q") - case 5: - enc.AddString("name", "R") - case 6: - enc.AddString("name", "X") - case 7: - enc.AddString("name", "Y") - case 8: - enc.AddString("name", "Z") - } - return nil -} - // Ptr returns a pointer to this enum value. func (v EnumWithDuplicateName) Ptr() *EnumWithDuplicateName { return &v @@ -638,19 +588,6 @@ func (v EnumWithDuplicateValues) MarshalText() ([]byte, error) { return []byte(strconv.FormatInt(int64(v), 10)), nil } -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of EnumWithDuplicateValues. -func (v EnumWithDuplicateValues) MarshalLogObject(enc zapcore.ObjectEncoder) error { - enc.AddInt32("value", int32(v)) - switch int32(v) { - case 0: - enc.AddString("name", "P") - case -1: - enc.AddString("name", "Q") - } - return nil -} - // Ptr returns a pointer to this enum value. func (v EnumWithDuplicateValues) Ptr() *EnumWithDuplicateValues { return &v @@ -809,21 +746,6 @@ func (v EnumWithValues) MarshalText() ([]byte, error) { return []byte(strconv.FormatInt(int64(v), 10)), nil } -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of EnumWithValues. -func (v EnumWithValues) MarshalLogObject(enc zapcore.ObjectEncoder) error { - enc.AddInt32("value", int32(v)) - switch int32(v) { - case 123: - enc.AddString("name", "X") - case 456: - enc.AddString("name", "Y") - case 789: - enc.AddString("name", "Z") - } - return nil -} - // Ptr returns a pointer to this enum value. func (v EnumWithValues) Ptr() *EnumWithValues { return &v @@ -994,21 +916,6 @@ func (v RecordType) MarshalText() ([]byte, error) { return []byte(strconv.FormatInt(int64(v), 10)), nil } -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of RecordType. -func (v RecordType) MarshalLogObject(enc zapcore.ObjectEncoder) error { - enc.AddInt32("value", int32(v)) - switch int32(v) { - case 0: - enc.AddString("name", "NAME") - case 1: - enc.AddString("name", "HOME_ADDRESS") - case 2: - enc.AddString("name", "WORK_ADDRESS") - } - return nil -} - // Ptr returns a pointer to this enum value. func (v RecordType) Ptr() *RecordType { return &v @@ -1164,19 +1071,6 @@ func (v RecordTypeValues) MarshalText() ([]byte, error) { return []byte(strconv.FormatInt(int64(v), 10)), nil } -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of RecordTypeValues. -func (v RecordTypeValues) MarshalLogObject(enc zapcore.ObjectEncoder) error { - enc.AddInt32("value", int32(v)) - switch int32(v) { - case 0: - enc.AddString("name", "FOO") - case 1: - enc.AddString("name", "BAR") - } - return nil -} - // Ptr returns a pointer to this enum value. func (v RecordTypeValues) Ptr() *RecordTypeValues { return &v @@ -1401,18 +1295,6 @@ func (v *StructWithOptionalEnum) Equals(rhs *StructWithOptionalEnum) bool { return true } -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of StructWithOptionalEnum. -func (v *StructWithOptionalEnum) MarshalLogObject(enc zapcore.ObjectEncoder) error { - if v.E != nil { - if err := enc.AddObject("e", *v.E); err != nil { - return err - } - } - - return nil -} - // GetE returns the value of E if it is set or its // zero value if it is unset. func (v *StructWithOptionalEnum) GetE() (o EnumDefault) { @@ -1479,21 +1361,6 @@ func (v LowerCaseEnum) MarshalText() ([]byte, error) { return []byte(strconv.FormatInt(int64(v), 10)), nil } -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of LowerCaseEnum. -func (v LowerCaseEnum) MarshalLogObject(enc zapcore.ObjectEncoder) error { - enc.AddInt32("value", int32(v)) - switch int32(v) { - case 0: - enc.AddString("name", "containing") - case 1: - enc.AddString("name", "lower_case") - case 2: - enc.AddString("name", "items") - } - return nil -} - // Ptr returns a pointer to this enum value. func (v LowerCaseEnum) Ptr() *LowerCaseEnum { return &v diff --git a/envelope/internal/tests/exceptions/types.go b/envelope/internal/tests/exceptions/types.go index 68367d58..9d32e7ae 100644 --- a/envelope/internal/tests/exceptions/types.go +++ b/envelope/internal/tests/exceptions/types.go @@ -27,7 +27,6 @@ import ( "errors" "fmt" "go.uber.org/thriftrw/wire" - "go.uber.org/zap/zapcore" "strings" ) @@ -175,17 +174,6 @@ func (v *DoesNotExistException) Equals(rhs *DoesNotExistException) bool { return true } -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of DoesNotExistException. -func (v *DoesNotExistException) MarshalLogObject(enc zapcore.ObjectEncoder) error { - enc.AddString("key", v.Key) - if v.Error2 != nil { - enc.AddString("Error", *v.Error2) - } - - return nil -} - // GetKey returns the value of Key if it is set or its // zero value if it is unset. func (v *DoesNotExistException) GetKey() (o string) { return v.Key } @@ -280,13 +268,6 @@ func (v *EmptyException) Equals(rhs *EmptyException) bool { return true } -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of EmptyException. -func (v *EmptyException) MarshalLogObject(enc zapcore.ObjectEncoder) error { - - return nil -} - func (v *EmptyException) Error() string { return v.String() } diff --git a/envelope/internal/tests/services/cache_clear.go b/envelope/internal/tests/services/cache_clear.go index c4504f33..d14e7e3d 100644 --- a/envelope/internal/tests/services/cache_clear.go +++ b/envelope/internal/tests/services/cache_clear.go @@ -26,7 +26,6 @@ package services import ( "fmt" "go.uber.org/thriftrw/wire" - "go.uber.org/zap/zapcore" "strings" ) @@ -109,13 +108,6 @@ func (v *Cache_Clear_Args) Equals(rhs *Cache_Clear_Args) bool { return true } -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of Cache_Clear_Args. -func (v *Cache_Clear_Args) MarshalLogObject(enc zapcore.ObjectEncoder) error { - - return nil -} - // MethodName returns the name of the Thrift function as specified in // the IDL, for which this struct represent the arguments. // diff --git a/envelope/internal/tests/services/cache_clearafter.go b/envelope/internal/tests/services/cache_clearafter.go index ad3cef6f..b252a172 100644 --- a/envelope/internal/tests/services/cache_clearafter.go +++ b/envelope/internal/tests/services/cache_clearafter.go @@ -26,7 +26,6 @@ package services import ( "fmt" "go.uber.org/thriftrw/wire" - "go.uber.org/zap/zapcore" "strings" ) @@ -149,16 +148,6 @@ func (v *Cache_ClearAfter_Args) Equals(rhs *Cache_ClearAfter_Args) bool { return true } -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of Cache_ClearAfter_Args. -func (v *Cache_ClearAfter_Args) MarshalLogObject(enc zapcore.ObjectEncoder) error { - if v.DurationMS != nil { - enc.AddInt64("durationMS", *v.DurationMS) - } - - return nil -} - // GetDurationMS returns the value of DurationMS if it is set or its // zero value if it is unset. func (v *Cache_ClearAfter_Args) GetDurationMS() (o int64) { diff --git a/envelope/internal/tests/services/conflictingnames_setvalue.go b/envelope/internal/tests/services/conflictingnames_setvalue.go index dc125706..e60fd4b8 100644 --- a/envelope/internal/tests/services/conflictingnames_setvalue.go +++ b/envelope/internal/tests/services/conflictingnames_setvalue.go @@ -26,7 +26,6 @@ package services import ( "fmt" "go.uber.org/thriftrw/wire" - "go.uber.org/zap/zapcore" "strings" ) @@ -143,18 +142,6 @@ func (v *ConflictingNames_SetValue_Args) Equals(rhs *ConflictingNames_SetValue_A return true } -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of ConflictingNames_SetValue_Args. -func (v *ConflictingNames_SetValue_Args) MarshalLogObject(enc zapcore.ObjectEncoder) error { - if v.Request != nil { - if err := enc.AddObject("request", v.Request); err != nil { - return err - } - } - - return nil -} - // GetRequest returns the value of Request if it is set or its // zero value if it is unset. func (v *ConflictingNames_SetValue_Args) GetRequest() (o *ConflictingNamesSetValueArgs) { @@ -334,13 +321,6 @@ func (v *ConflictingNames_SetValue_Result) Equals(rhs *ConflictingNames_SetValue return true } -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of ConflictingNames_SetValue_Result. -func (v *ConflictingNames_SetValue_Result) MarshalLogObject(enc zapcore.ObjectEncoder) error { - - return nil -} - // MethodName returns the name of the Thrift function as specified in // the IDL, for which this struct represent the result. // diff --git a/envelope/internal/tests/services/keyvalue_deletevalue.go b/envelope/internal/tests/services/keyvalue_deletevalue.go index 3845f651..11237978 100644 --- a/envelope/internal/tests/services/keyvalue_deletevalue.go +++ b/envelope/internal/tests/services/keyvalue_deletevalue.go @@ -28,7 +28,6 @@ import ( "fmt" "go.uber.org/thriftrw/envelope/internal/tests/exceptions" "go.uber.org/thriftrw/wire" - "go.uber.org/zap/zapcore" "strings" ) @@ -157,16 +156,6 @@ func (v *KeyValue_DeleteValue_Args) Equals(rhs *KeyValue_DeleteValue_Args) bool return true } -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of KeyValue_DeleteValue_Args. -func (v *KeyValue_DeleteValue_Args) MarshalLogObject(enc zapcore.ObjectEncoder) error { - if v.Key != nil { - enc.AddString("key", (string)(*v.Key)) - } - - return nil -} - // GetKey returns the value of Key if it is set or its // zero value if it is unset. func (v *KeyValue_DeleteValue_Args) GetKey() (o Key) { @@ -451,23 +440,6 @@ func (v *KeyValue_DeleteValue_Result) Equals(rhs *KeyValue_DeleteValue_Result) b return true } -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of KeyValue_DeleteValue_Result. -func (v *KeyValue_DeleteValue_Result) MarshalLogObject(enc zapcore.ObjectEncoder) error { - if v.DoesNotExist != nil { - if err := enc.AddObject("doesNotExist", v.DoesNotExist); err != nil { - return err - } - } - if v.InternalError != nil { - if err := enc.AddObject("internalError", v.InternalError); err != nil { - return err - } - } - - return nil -} - // GetDoesNotExist returns the value of DoesNotExist if it is set or its // zero value if it is unset. func (v *KeyValue_DeleteValue_Result) GetDoesNotExist() (o *exceptions.DoesNotExistException) { diff --git a/envelope/internal/tests/services/keyvalue_getmanyvalues.go b/envelope/internal/tests/services/keyvalue_getmanyvalues.go index 9125451c..d64969ca 100644 --- a/envelope/internal/tests/services/keyvalue_getmanyvalues.go +++ b/envelope/internal/tests/services/keyvalue_getmanyvalues.go @@ -29,7 +29,6 @@ import ( "go.uber.org/thriftrw/envelope/internal/tests/exceptions" "go.uber.org/thriftrw/envelope/internal/tests/unions" "go.uber.org/thriftrw/wire" - "go.uber.org/zap/zapcore" "strings" ) @@ -199,29 +198,6 @@ func (v *KeyValue_GetManyValues_Args) Equals(rhs *KeyValue_GetManyValues_Args) b return true } -type _List_Key_Zapper []Key - -// MarshalLogArray implements zapcore.ArrayMarshaler, enabling -// fast logging of _List_Key_Zapper. -func (l _List_Key_Zapper) MarshalLogArray(enc zapcore.ArrayEncoder) error { - for _, v := range l { - enc.AppendString((string)(v)) - } - return nil -} - -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of KeyValue_GetManyValues_Args. -func (v *KeyValue_GetManyValues_Args) MarshalLogObject(enc zapcore.ObjectEncoder) error { - if v.Range != nil { - if err := enc.AddArray("range", (_List_Key_Zapper)(v.Range)); err != nil { - return err - } - } - - return nil -} - // GetRange returns the value of Range if it is set or its // zero value if it is unset. func (v *KeyValue_GetManyValues_Args) GetRange() (o []Key) { @@ -559,36 +535,6 @@ func (v *KeyValue_GetManyValues_Result) Equals(rhs *KeyValue_GetManyValues_Resul return true } -type _List_ArbitraryValue_Zapper []*unions.ArbitraryValue - -// MarshalLogArray implements zapcore.ArrayMarshaler, enabling -// fast logging of _List_ArbitraryValue_Zapper. -func (l _List_ArbitraryValue_Zapper) MarshalLogArray(enc zapcore.ArrayEncoder) error { - for _, v := range l { - if err := enc.AppendObject(v); err != nil { - return err - } - } - return nil -} - -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of KeyValue_GetManyValues_Result. -func (v *KeyValue_GetManyValues_Result) MarshalLogObject(enc zapcore.ObjectEncoder) error { - if v.Success != nil { - if err := enc.AddArray("success", (_List_ArbitraryValue_Zapper)(v.Success)); err != nil { - return err - } - } - if v.DoesNotExist != nil { - if err := enc.AddObject("doesNotExist", v.DoesNotExist); err != nil { - return err - } - } - - return nil -} - // GetSuccess returns the value of Success if it is set or its // zero value if it is unset. func (v *KeyValue_GetManyValues_Result) GetSuccess() (o []*unions.ArbitraryValue) { diff --git a/envelope/internal/tests/services/keyvalue_getvalue.go b/envelope/internal/tests/services/keyvalue_getvalue.go index e460e5a1..3d4b652a 100644 --- a/envelope/internal/tests/services/keyvalue_getvalue.go +++ b/envelope/internal/tests/services/keyvalue_getvalue.go @@ -29,7 +29,6 @@ import ( "go.uber.org/thriftrw/envelope/internal/tests/exceptions" "go.uber.org/thriftrw/envelope/internal/tests/unions" "go.uber.org/thriftrw/wire" - "go.uber.org/zap/zapcore" "strings" ) @@ -142,16 +141,6 @@ func (v *KeyValue_GetValue_Args) Equals(rhs *KeyValue_GetValue_Args) bool { return true } -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of KeyValue_GetValue_Args. -func (v *KeyValue_GetValue_Args) MarshalLogObject(enc zapcore.ObjectEncoder) error { - if v.Key != nil { - enc.AddString("key", (string)(*v.Key)) - } - - return nil -} - // GetKey returns the value of Key if it is set or its // zero value if it is unset. func (v *KeyValue_GetValue_Args) GetKey() (o Key) { @@ -421,23 +410,6 @@ func (v *KeyValue_GetValue_Result) Equals(rhs *KeyValue_GetValue_Result) bool { return true } -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of KeyValue_GetValue_Result. -func (v *KeyValue_GetValue_Result) MarshalLogObject(enc zapcore.ObjectEncoder) error { - if v.Success != nil { - if err := enc.AddObject("success", v.Success); err != nil { - return err - } - } - if v.DoesNotExist != nil { - if err := enc.AddObject("doesNotExist", v.DoesNotExist); err != nil { - return err - } - } - - return nil -} - // GetSuccess returns the value of Success if it is set or its // zero value if it is unset. func (v *KeyValue_GetValue_Result) GetSuccess() (o *unions.ArbitraryValue) { diff --git a/envelope/internal/tests/services/keyvalue_setvalue.go b/envelope/internal/tests/services/keyvalue_setvalue.go index 95e3e4bf..e106573d 100644 --- a/envelope/internal/tests/services/keyvalue_setvalue.go +++ b/envelope/internal/tests/services/keyvalue_setvalue.go @@ -27,7 +27,6 @@ import ( "fmt" "go.uber.org/thriftrw/envelope/internal/tests/unions" "go.uber.org/thriftrw/wire" - "go.uber.org/zap/zapcore" "strings" ) @@ -164,21 +163,6 @@ func (v *KeyValue_SetValue_Args) Equals(rhs *KeyValue_SetValue_Args) bool { return true } -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of KeyValue_SetValue_Args. -func (v *KeyValue_SetValue_Args) MarshalLogObject(enc zapcore.ObjectEncoder) error { - if v.Key != nil { - enc.AddString("key", (string)(*v.Key)) - } - if v.Value != nil { - if err := enc.AddObject("value", v.Value); err != nil { - return err - } - } - - return nil -} - // GetKey returns the value of Key if it is set or its // zero value if it is unset. func (v *KeyValue_SetValue_Args) GetKey() (o Key) { @@ -371,13 +355,6 @@ func (v *KeyValue_SetValue_Result) Equals(rhs *KeyValue_SetValue_Result) bool { return true } -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of KeyValue_SetValue_Result. -func (v *KeyValue_SetValue_Result) MarshalLogObject(enc zapcore.ObjectEncoder) error { - - return nil -} - // MethodName returns the name of the Thrift function as specified in // the IDL, for which this struct represent the result. // diff --git a/envelope/internal/tests/services/keyvalue_setvaluev2.go b/envelope/internal/tests/services/keyvalue_setvaluev2.go index 1ffe9fd1..f7d6e216 100644 --- a/envelope/internal/tests/services/keyvalue_setvaluev2.go +++ b/envelope/internal/tests/services/keyvalue_setvaluev2.go @@ -28,7 +28,6 @@ import ( "fmt" "go.uber.org/thriftrw/envelope/internal/tests/unions" "go.uber.org/thriftrw/wire" - "go.uber.org/zap/zapcore" "strings" ) @@ -173,18 +172,6 @@ func (v *KeyValue_SetValueV2_Args) Equals(rhs *KeyValue_SetValueV2_Args) bool { return true } -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of KeyValue_SetValueV2_Args. -func (v *KeyValue_SetValueV2_Args) MarshalLogObject(enc zapcore.ObjectEncoder) error { - enc.AddString("key", (string)(v.Key)) - - if err := enc.AddObject("value", v.Value); err != nil { - return err - } - - return nil -} - // GetKey returns the value of Key if it is set or its // zero value if it is unset. func (v *KeyValue_SetValueV2_Args) GetKey() (o Key) { return v.Key } @@ -365,13 +352,6 @@ func (v *KeyValue_SetValueV2_Result) Equals(rhs *KeyValue_SetValueV2_Result) boo return true } -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of KeyValue_SetValueV2_Result. -func (v *KeyValue_SetValueV2_Result) MarshalLogObject(enc zapcore.ObjectEncoder) error { - - return nil -} - // MethodName returns the name of the Thrift function as specified in // the IDL, for which this struct represent the result. // diff --git a/envelope/internal/tests/services/keyvalue_size.go b/envelope/internal/tests/services/keyvalue_size.go index 5175d448..4ccdffa3 100644 --- a/envelope/internal/tests/services/keyvalue_size.go +++ b/envelope/internal/tests/services/keyvalue_size.go @@ -27,7 +27,6 @@ import ( "errors" "fmt" "go.uber.org/thriftrw/wire" - "go.uber.org/zap/zapcore" "strings" ) @@ -110,13 +109,6 @@ func (v *KeyValue_Size_Args) Equals(rhs *KeyValue_Size_Args) bool { return true } -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of KeyValue_Size_Args. -func (v *KeyValue_Size_Args) MarshalLogObject(enc zapcore.ObjectEncoder) error { - - return nil -} - // MethodName returns the name of the Thrift function as specified in // the IDL, for which this struct represent the arguments. // @@ -331,16 +323,6 @@ func (v *KeyValue_Size_Result) Equals(rhs *KeyValue_Size_Result) bool { return true } -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of KeyValue_Size_Result. -func (v *KeyValue_Size_Result) MarshalLogObject(enc zapcore.ObjectEncoder) error { - if v.Success != nil { - enc.AddInt64("success", *v.Success) - } - - return nil -} - // GetSuccess returns the value of Success if it is set or its // zero value if it is unset. func (v *KeyValue_Size_Result) GetSuccess() (o int64) { diff --git a/envelope/internal/tests/services/non_standard_service_name_non_standard_function_name.go b/envelope/internal/tests/services/non_standard_service_name_non_standard_function_name.go index 1f7f715a..5102ff40 100644 --- a/envelope/internal/tests/services/non_standard_service_name_non_standard_function_name.go +++ b/envelope/internal/tests/services/non_standard_service_name_non_standard_function_name.go @@ -26,7 +26,6 @@ package services import ( "fmt" "go.uber.org/thriftrw/wire" - "go.uber.org/zap/zapcore" "strings" ) @@ -109,13 +108,6 @@ func (v *NonStandardServiceName_NonStandardFunctionName_Args) Equals(rhs *NonSta return true } -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of NonStandardServiceName_NonStandardFunctionName_Args. -func (v *NonStandardServiceName_NonStandardFunctionName_Args) MarshalLogObject(enc zapcore.ObjectEncoder) error { - - return nil -} - // MethodName returns the name of the Thrift function as specified in // the IDL, for which this struct represent the arguments. // @@ -279,13 +271,6 @@ func (v *NonStandardServiceName_NonStandardFunctionName_Result) Equals(rhs *NonS return true } -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of NonStandardServiceName_NonStandardFunctionName_Result. -func (v *NonStandardServiceName_NonStandardFunctionName_Result) MarshalLogObject(enc zapcore.ObjectEncoder) error { - - return nil -} - // MethodName returns the name of the Thrift function as specified in // the IDL, for which this struct represent the result. // diff --git a/envelope/internal/tests/services/types.go b/envelope/internal/tests/services/types.go index b77748c0..c79a4421 100644 --- a/envelope/internal/tests/services/types.go +++ b/envelope/internal/tests/services/types.go @@ -25,11 +25,9 @@ package services import ( "bytes" - "encoding/base64" "errors" "fmt" "go.uber.org/thriftrw/wire" - "go.uber.org/zap/zapcore" "strings" ) @@ -167,15 +165,6 @@ func (v *ConflictingNamesSetValueArgs) Equals(rhs *ConflictingNamesSetValueArgs) return true } -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of ConflictingNamesSetValueArgs. -func (v *ConflictingNamesSetValueArgs) MarshalLogObject(enc zapcore.ObjectEncoder) error { - enc.AddString("key", v.Key) - enc.AddString("value", base64.StdEncoding.EncodeToString(v.Value)) - - return nil -} - // GetKey returns the value of Key if it is set or its // zero value if it is unset. func (v *ConflictingNamesSetValueArgs) GetKey() (o string) { return v.Key } @@ -300,16 +289,6 @@ func (v *InternalError) Equals(rhs *InternalError) bool { return true } -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of InternalError. -func (v *InternalError) MarshalLogObject(enc zapcore.ObjectEncoder) error { - if v.Message != nil { - enc.AddString("message", *v.Message) - } - - return nil -} - // GetMessage returns the value of Message if it is set or its // zero value if it is unset. func (v *InternalError) GetMessage() (o string) { diff --git a/envelope/internal/tests/structs/types.go b/envelope/internal/tests/structs/types.go index df7c30d3..d49b9393 100644 --- a/envelope/internal/tests/structs/types.go +++ b/envelope/internal/tests/structs/types.go @@ -25,13 +25,11 @@ package structs import ( "bytes" - "encoding/base64" "errors" "fmt" "go.uber.org/thriftrw/envelope/internal/tests/enums" "go.uber.org/thriftrw/ptr" "go.uber.org/thriftrw/wire" - "go.uber.org/zap/zapcore" "strings" ) @@ -141,14 +139,6 @@ func (v *ContactInfo) Equals(rhs *ContactInfo) bool { return true } -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of ContactInfo. -func (v *ContactInfo) MarshalLogObject(enc zapcore.ObjectEncoder) error { - enc.AddString("emailAddress", v.EmailAddress) - - return nil -} - // GetEmailAddress returns the value of EmailAddress if it is set or its // zero value if it is unset. func (v *ContactInfo) GetEmailAddress() (o string) { return v.EmailAddress } @@ -699,71 +689,6 @@ func (v *DefaultsStruct) Equals(rhs *DefaultsStruct) bool { return true } -type _List_String_Zapper []string - -// MarshalLogArray implements zapcore.ArrayMarshaler, enabling -// fast logging of _List_String_Zapper. -func (l _List_String_Zapper) MarshalLogArray(enc zapcore.ArrayEncoder) error { - for _, v := range l { - enc.AppendString(v) - } - return nil -} - -type _List_Double_Zapper []float64 - -// MarshalLogArray implements zapcore.ArrayMarshaler, enabling -// fast logging of _List_Double_Zapper. -func (l _List_Double_Zapper) MarshalLogArray(enc zapcore.ArrayEncoder) error { - for _, v := range l { - enc.AppendFloat64(v) - } - return nil -} - -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of DefaultsStruct. -func (v *DefaultsStruct) MarshalLogObject(enc zapcore.ObjectEncoder) error { - if v.RequiredPrimitive != nil { - enc.AddInt32("requiredPrimitive", *v.RequiredPrimitive) - } - if v.OptionalPrimitive != nil { - enc.AddInt32("optionalPrimitive", *v.OptionalPrimitive) - } - if v.RequiredEnum != nil { - if err := enc.AddObject("requiredEnum", *v.RequiredEnum); err != nil { - return err - } - } - if v.OptionalEnum != nil { - if err := enc.AddObject("optionalEnum", *v.OptionalEnum); err != nil { - return err - } - } - if v.RequiredList != nil { - if err := enc.AddArray("requiredList", (_List_String_Zapper)(v.RequiredList)); err != nil { - return err - } - } - if v.OptionalList != nil { - if err := enc.AddArray("optionalList", (_List_Double_Zapper)(v.OptionalList)); err != nil { - return err - } - } - if v.RequiredStruct != nil { - if err := enc.AddObject("requiredStruct", v.RequiredStruct); err != nil { - return err - } - } - if v.OptionalStruct != nil { - if err := enc.AddObject("optionalStruct", v.OptionalStruct); err != nil { - return err - } - } - - return nil -} - // GetRequiredPrimitive returns the value of RequiredPrimitive if it is set or its // default value if it is unset. func (v *DefaultsStruct) GetRequiredPrimitive() (o int32) { @@ -1012,21 +937,6 @@ func (v *Edge) Equals(rhs *Edge) bool { return true } -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of Edge. -func (v *Edge) MarshalLogObject(enc zapcore.ObjectEncoder) error { - - if err := enc.AddObject("startPoint", v.StartPoint); err != nil { - return err - } - - if err := enc.AddObject("endPoint", v.EndPoint); err != nil { - return err - } - - return nil -} - // GetStartPoint returns the value of StartPoint if it is set or its // zero value if it is unset. func (v *Edge) GetStartPoint() (o *Point) { return v.StartPoint } @@ -1111,13 +1021,6 @@ func (v *EmptyStruct) Equals(rhs *EmptyStruct) bool { return true } -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of EmptyStruct. -func (v *EmptyStruct) MarshalLogObject(enc zapcore.ObjectEncoder) error { - - return nil -} - type Frame struct { TopLeft *Point `json:"topLeft,required"` Size *Size `json:"size,required"` @@ -1261,21 +1164,6 @@ func (v *Frame) Equals(rhs *Frame) bool { return true } -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of Frame. -func (v *Frame) MarshalLogObject(enc zapcore.ObjectEncoder) error { - - if err := enc.AddObject("topLeft", v.TopLeft); err != nil { - return err - } - - if err := enc.AddObject("size", v.Size); err != nil { - return err - } - - return nil -} - // GetTopLeft returns the value of TopLeft if it is set or its // zero value if it is unset. func (v *Frame) GetTopLeft() (o *Point) { return v.TopLeft } @@ -1532,23 +1420,6 @@ func (v *GoTags) Equals(rhs *GoTags) bool { return true } -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of GoTags. -func (v *GoTags) MarshalLogObject(enc zapcore.ObjectEncoder) error { - enc.AddString("Foo", v.Foo) - if v.Bar != nil { - enc.AddString("Bar", *v.Bar) - } - enc.AddString("FooBar", v.FooBar) - enc.AddString("FooBarWithSpace", v.FooBarWithSpace) - if v.FooBarWithOmitEmpty != nil { - enc.AddString("FooBarWithOmitEmpty", *v.FooBarWithOmitEmpty) - } - enc.AddString("FooBarWithRequired", v.FooBarWithRequired) - - return nil -} - // GetFoo returns the value of Foo if it is set or its // zero value if it is unset. func (v *GoTags) GetFoo() (o string) { return v.Foo } @@ -1760,30 +1631,6 @@ func (v *Graph) Equals(rhs *Graph) bool { return true } -type _List_Edge_Zapper []*Edge - -// MarshalLogArray implements zapcore.ArrayMarshaler, enabling -// fast logging of _List_Edge_Zapper. -func (l _List_Edge_Zapper) MarshalLogArray(enc zapcore.ArrayEncoder) error { - for _, v := range l { - if err := enc.AppendObject(v); err != nil { - return err - } - } - return nil -} - -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of Graph. -func (v *Graph) MarshalLogObject(enc zapcore.ObjectEncoder) error { - - if err := enc.AddArray("edges", (_List_Edge_Zapper)(v.Edges)); err != nil { - return err - } - - return nil -} - // GetEdges returns the value of Edges if it is set or its // zero value if it is unset. func (v *Graph) GetEdges() (o []*Edge) { return v.Edges } @@ -1817,10 +1664,6 @@ func (lhs *List) Equals(rhs *List) bool { return (*Node)(lhs).Equals((*Node)(rhs)) } -func (v *List) MarshalLogObject(enc zapcore.ObjectEncoder) error { - return ((*Node)(v)).MarshalLogObject(enc) -} - // Node is linked list of values. // All values are 32-bit integers. type Node struct { @@ -1959,19 +1802,6 @@ func (v *Node) Equals(rhs *Node) bool { return true } -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of Node. -func (v *Node) MarshalLogObject(enc zapcore.ObjectEncoder) error { - enc.AddInt32("value", v.Value) - if v.Tail != nil { - if err := enc.AddObject("tail", (*Node)(v.Tail)); err != nil { - return err - } - } - - return nil -} - // GetValue returns the value of Value if it is set or its // zero value if it is unset. func (v *Node) GetValue() (o int32) { return v.Value } @@ -2118,15 +1948,6 @@ func (v *Omit) Equals(rhs *Omit) bool { return true } -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of Omit. -func (v *Omit) MarshalLogObject(enc zapcore.ObjectEncoder) error { - enc.AddString("serialized", v.Serialized) - enc.AddString("hidden", v.Hidden) - - return nil -} - // GetSerialized returns the value of Serialized if it is set or its // zero value if it is unset. func (v *Omit) GetSerialized() (o string) { return v.Serialized } @@ -2268,15 +2089,6 @@ func (v *Point) Equals(rhs *Point) bool { return true } -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of Point. -func (v *Point) MarshalLogObject(enc zapcore.ObjectEncoder) error { - enc.AddFloat64("x", v.X) - enc.AddFloat64("y", v.Y) - - return nil -} - // GetX returns the value of X if it is set or its // zero value if it is unset. func (v *Point) GetX() (o float64) { return v.X } @@ -2624,37 +2436,6 @@ func (v *PrimitiveOptionalStruct) Equals(rhs *PrimitiveOptionalStruct) bool { return true } -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of PrimitiveOptionalStruct. -func (v *PrimitiveOptionalStruct) MarshalLogObject(enc zapcore.ObjectEncoder) error { - if v.BoolField != nil { - enc.AddBool("boolField", *v.BoolField) - } - if v.ByteField != nil { - enc.AddInt8("byteField", *v.ByteField) - } - if v.Int16Field != nil { - enc.AddInt16("int16Field", *v.Int16Field) - } - if v.Int32Field != nil { - enc.AddInt32("int32Field", *v.Int32Field) - } - if v.Int64Field != nil { - enc.AddInt64("int64Field", *v.Int64Field) - } - if v.DoubleField != nil { - enc.AddFloat64("doubleField", *v.DoubleField) - } - if v.StringField != nil { - enc.AddString("stringField", *v.StringField) - } - if v.BinaryField != nil { - enc.AddString("binaryField", base64.StdEncoding.EncodeToString(v.BinaryField)) - } - - return nil -} - // GetBoolField returns the value of BoolField if it is set or its // zero value if it is unset. func (v *PrimitiveOptionalStruct) GetBoolField() (o bool) { @@ -3028,21 +2809,6 @@ func (v *PrimitiveRequiredStruct) Equals(rhs *PrimitiveRequiredStruct) bool { return true } -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of PrimitiveRequiredStruct. -func (v *PrimitiveRequiredStruct) MarshalLogObject(enc zapcore.ObjectEncoder) error { - enc.AddBool("boolField", v.BoolField) - enc.AddInt8("byteField", v.ByteField) - enc.AddInt16("int16Field", v.Int16Field) - enc.AddInt32("int32Field", v.Int32Field) - enc.AddInt64("int64Field", v.Int64Field) - enc.AddFloat64("doubleField", v.DoubleField) - enc.AddString("stringField", v.StringField) - enc.AddString("binaryField", base64.StdEncoding.EncodeToString(v.BinaryField)) - - return nil -} - // GetBoolField returns the value of BoolField if it is set or its // zero value if it is unset. func (v *PrimitiveRequiredStruct) GetBoolField() (o bool) { return v.BoolField } @@ -3207,15 +2973,6 @@ func (v *Rename) Equals(rhs *Rename) bool { return true } -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of Rename. -func (v *Rename) MarshalLogObject(enc zapcore.ObjectEncoder) error { - enc.AddString("Default", v.Default) - enc.AddString("camelCase", v.CamelCase) - - return nil -} - // GetDefault returns the value of Default if it is set or its // zero value if it is unset. func (v *Rename) GetDefault() (o string) { return v.Default } @@ -3359,15 +3116,6 @@ func (v *Size) Equals(rhs *Size) bool { return true } -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of Size. -func (v *Size) MarshalLogObject(enc zapcore.ObjectEncoder) error { - enc.AddFloat64("width", v.Width) - enc.AddFloat64("height", v.Height) - - return nil -} - // GetWidth returns the value of Width if it is set or its // zero value if it is unset. func (v *Size) GetWidth() (o float64) { return v.Width } @@ -3512,19 +3260,6 @@ func (v *User) Equals(rhs *User) bool { return true } -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of User. -func (v *User) MarshalLogObject(enc zapcore.ObjectEncoder) error { - enc.AddString("name", v.Name) - if v.Contact != nil { - if err := enc.AddObject("contact", v.Contact); err != nil { - return err - } - } - - return nil -} - // GetName returns the value of Name if it is set or its // zero value if it is unset. func (v *User) GetName() (o string) { return v.Name } diff --git a/envelope/internal/tests/typedefs/types.go b/envelope/internal/tests/typedefs/types.go index 1229a50f..85e06616 100644 --- a/envelope/internal/tests/typedefs/types.go +++ b/envelope/internal/tests/typedefs/types.go @@ -25,13 +25,11 @@ package typedefs import ( "bytes" - "encoding/base64" "errors" "fmt" "go.uber.org/thriftrw/envelope/internal/tests/enums" "go.uber.org/thriftrw/envelope/internal/tests/structs" "go.uber.org/thriftrw/wire" - "go.uber.org/zap/zapcore" "strings" ) @@ -104,17 +102,6 @@ func _Set_Binary_Equals(lhs, rhs [][]byte) bool { return true } -type _BinarySet_Zapper [][]byte - -// MarshalLogArray implements zapcore.ArrayMarshaler, enabling -// fast logging of _BinarySet_Zapper. -func (s _BinarySet_Zapper) MarshalLogArray(enc zapcore.ArrayEncoder) error { - for _, v := range s { - enc.AppendString(base64.StdEncoding.EncodeToString(v)) - } - return nil -} - type BinarySet [][]byte // ToWire translates BinarySet into a Thrift-level intermediate @@ -146,10 +133,6 @@ func (lhs BinarySet) Equals(rhs BinarySet) bool { return _Set_Binary_Equals(lhs, rhs) } -func (v BinarySet) MarshalLogArray(enc zapcore.ArrayEncoder) error { - return ((_BinarySet_Zapper)(([][]byte)(v))).MarshalLogArray(enc) -} - type DefaultPrimitiveTypedef struct { State *State `json:"state,omitempty"` } @@ -283,16 +266,6 @@ func (v *DefaultPrimitiveTypedef) Equals(rhs *DefaultPrimitiveTypedef) bool { return true } -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of DefaultPrimitiveTypedef. -func (v *DefaultPrimitiveTypedef) MarshalLogObject(enc zapcore.ObjectEncoder) error { - if v.State != nil { - enc.AddString("state", (string)(*v.State)) - } - - return nil -} - // GetState returns the value of State if it is set or its // default value if it is unset. func (v *DefaultPrimitiveTypedef) GetState() (o State) { @@ -425,41 +398,6 @@ func _Map_Edge_Edge_Equals(lhs, rhs []struct { return true } -type _MapItem_Edge_Edge_Zapper struct { - Key *structs.Edge - Value *structs.Edge -} - -// MarshalLogArray implements zapcore.ArrayMarshaler, enabling -// fast logging of _MapItem_Edge_Edge_Zapper. -func (v _MapItem_Edge_Edge_Zapper) MarshalLogObject(enc zapcore.ObjectEncoder) error { - if err := enc.AddObject("key", v.Key); err != nil { - return err - } - if err := enc.AddObject("value", v.Value); err != nil { - return err - } - return nil -} - -type _EdgeMap_Zapper []struct { - Key *structs.Edge - Value *structs.Edge -} - -// MarshalLogArray implements zapcore.ArrayMarshaler, enabling -// fast logging of _EdgeMap_Zapper. -func (m _EdgeMap_Zapper) MarshalLogArray(enc zapcore.ArrayEncoder) error { - for _, i := range m { - k := i.Key - v := i.Value - if err := enc.AppendObject(_MapItem_Edge_Edge_Zapper{Key: k, Value: v}); err != nil { - return err - } - } - return nil -} - type EdgeMap []struct { Key *structs.Edge Value *structs.Edge @@ -500,13 +438,6 @@ func (lhs EdgeMap) Equals(rhs EdgeMap) bool { return _Map_Edge_Edge_Equals(lhs, rhs) } -func (v EdgeMap) MarshalLogArray(enc zapcore.ArrayEncoder) error { - return ((_EdgeMap_Zapper)(([]struct { - Key *structs.Edge - Value *structs.Edge - })(v))).MarshalLogArray(enc) -} - type Event struct { UUID *UUID `json:"uuid,required"` Time *Timestamp `json:"time,omitempty"` @@ -664,20 +595,6 @@ func (v *Event) Equals(rhs *Event) bool { return true } -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of Event. -func (v *Event) MarshalLogObject(enc zapcore.ObjectEncoder) error { - - if err := enc.AddObject("uuid", (*I128)(v.UUID)); err != nil { - return err - } - if v.Time != nil { - enc.AddInt64("time", (int64)(*v.Time)) - } - - return nil -} - // GetUUID returns the value of UUID if it is set or its // zero value if it is unset. func (v *Event) GetUUID() (o *UUID) { return v.UUID } @@ -760,19 +677,6 @@ func _List_Event_Equals(lhs, rhs []*Event) bool { return true } -type _EventGroup_Zapper []*Event - -// MarshalLogArray implements zapcore.ArrayMarshaler, enabling -// fast logging of _EventGroup_Zapper. -func (l _EventGroup_Zapper) MarshalLogArray(enc zapcore.ArrayEncoder) error { - for _, v := range l { - if err := enc.AppendObject(v); err != nil { - return err - } - } - return nil -} - type EventGroup []*Event // ToWire translates EventGroup into a Thrift-level intermediate @@ -804,10 +708,6 @@ func (lhs EventGroup) Equals(rhs EventGroup) bool { return _List_Event_Equals(lhs, rhs) } -func (v EventGroup) MarshalLogArray(enc zapcore.ArrayEncoder) error { - return ((_EventGroup_Zapper)(([]*Event)(v))).MarshalLogArray(enc) -} - type _Set_Frame_ValueList []*structs.Frame func (v _Set_Frame_ValueList) ForEach(f func(wire.Value) error) error { @@ -883,19 +783,6 @@ func _Set_Frame_Equals(lhs, rhs []*structs.Frame) bool { return true } -type _FrameGroup_Zapper []*structs.Frame - -// MarshalLogArray implements zapcore.ArrayMarshaler, enabling -// fast logging of _FrameGroup_Zapper. -func (s _FrameGroup_Zapper) MarshalLogArray(enc zapcore.ArrayEncoder) error { - for _, v := range s { - if err := enc.AppendObject(v); err != nil { - return err - } - } - return nil -} - type FrameGroup []*structs.Frame // ToWire translates FrameGroup into a Thrift-level intermediate @@ -927,10 +814,6 @@ func (lhs FrameGroup) Equals(rhs FrameGroup) bool { return _Set_Frame_Equals(lhs, rhs) } -func (v FrameGroup) MarshalLogArray(enc zapcore.ArrayEncoder) error { - return ((_FrameGroup_Zapper)(([]*structs.Frame)(v))).MarshalLogArray(enc) -} - func _EnumWithValues_Read(w wire.Value) (enums.EnumWithValues, error) { var v enums.EnumWithValues err := v.FromWire(w) @@ -968,10 +851,6 @@ func (lhs MyEnum) Equals(rhs MyEnum) bool { return lhs.Equals(rhs) } -func (v MyEnum) MarshalLogObject(enc zapcore.ObjectEncoder) error { - return ((enums.EnumWithValues)(v)).MarshalLogObject(enc) -} - type PDF []byte // ToWire translates PDF into a Thrift-level intermediate @@ -1125,41 +1004,6 @@ func _Map_Point_Point_Equals(lhs, rhs []struct { return true } -type _MapItem_Point_Point_Zapper struct { - Key *structs.Point - Value *structs.Point -} - -// MarshalLogArray implements zapcore.ArrayMarshaler, enabling -// fast logging of _MapItem_Point_Point_Zapper. -func (v _MapItem_Point_Point_Zapper) MarshalLogObject(enc zapcore.ObjectEncoder) error { - if err := enc.AddObject("key", v.Key); err != nil { - return err - } - if err := enc.AddObject("value", v.Value); err != nil { - return err - } - return nil -} - -type _PointMap_Zapper []struct { - Key *structs.Point - Value *structs.Point -} - -// MarshalLogArray implements zapcore.ArrayMarshaler, enabling -// fast logging of _PointMap_Zapper. -func (m _PointMap_Zapper) MarshalLogArray(enc zapcore.ArrayEncoder) error { - for _, i := range m { - k := i.Key - v := i.Value - if err := enc.AppendObject(_MapItem_Point_Point_Zapper{Key: k, Value: v}); err != nil { - return err - } - } - return nil -} - type PointMap []struct { Key *structs.Point Value *structs.Point @@ -1200,13 +1044,6 @@ func (lhs PointMap) Equals(rhs PointMap) bool { return _Map_Point_Point_Equals(lhs, rhs) } -func (v PointMap) MarshalLogArray(enc zapcore.ArrayEncoder) error { - return ((_PointMap_Zapper)(([]struct { - Key *structs.Point - Value *structs.Point - })(v))).MarshalLogArray(enc) -} - type State string // ToWire translates State into a Thrift-level intermediate @@ -1434,20 +1271,6 @@ func (v *Transition) Equals(rhs *Transition) bool { return true } -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of Transition. -func (v *Transition) MarshalLogObject(enc zapcore.ObjectEncoder) error { - enc.AddString("fromState", (string)(v.FromState)) - enc.AddString("toState", (string)(v.ToState)) - if v.Events != nil { - if err := enc.AddArray("events", (_EventGroup_Zapper)(([]*Event)(v.Events))); err != nil { - return err - } - } - - return nil -} - // GetFromState returns the value of FromState if it is set or its // zero value if it is unset. func (v *Transition) GetFromState() (o State) { return v.FromState } @@ -1495,10 +1318,6 @@ func (lhs *UUID) Equals(rhs *UUID) bool { return (*I128)(lhs).Equals((*I128)(rhs)) } -func (v *UUID) MarshalLogObject(enc zapcore.ObjectEncoder) error { - return ((*I128)(v)).MarshalLogObject(enc) -} - type I128 struct { High int64 `json:"high,required"` Low int64 `json:"low,required"` @@ -1631,15 +1450,6 @@ func (v *I128) Equals(rhs *I128) bool { return true } -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of I128. -func (v *I128) MarshalLogObject(enc zapcore.ObjectEncoder) error { - enc.AddInt64("high", v.High) - enc.AddInt64("low", v.Low) - - return nil -} - // GetHigh returns the value of High if it is set or its // zero value if it is unset. func (v *I128) GetHigh() (o int64) { return v.High } diff --git a/envelope/internal/tests/unions/types.go b/envelope/internal/tests/unions/types.go index 715ffdb3..b0de22cc 100644 --- a/envelope/internal/tests/unions/types.go +++ b/envelope/internal/tests/unions/types.go @@ -24,11 +24,9 @@ package unions import ( - "encoding/base64" "fmt" "go.uber.org/thriftrw/envelope/internal/tests/typedefs" "go.uber.org/thriftrw/wire" - "go.uber.org/zap/zapcore" "strings" ) @@ -452,58 +450,6 @@ func (v *ArbitraryValue) Equals(rhs *ArbitraryValue) bool { return true } -type _List_ArbitraryValue_Zapper []*ArbitraryValue - -// MarshalLogArray implements zapcore.ArrayMarshaler, enabling -// fast logging of _List_ArbitraryValue_Zapper. -func (l _List_ArbitraryValue_Zapper) MarshalLogArray(enc zapcore.ArrayEncoder) error { - for _, v := range l { - if err := enc.AppendObject(v); err != nil { - return err - } - } - return nil -} - -type _Map_String_ArbitraryValue_Zapper map[string]*ArbitraryValue - -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of _Map_String_ArbitraryValue_Zapper. -func (m _Map_String_ArbitraryValue_Zapper) MarshalLogObject(enc zapcore.ObjectEncoder) error { - for k, v := range m { - if err := enc.AddObject((string)(k), v); err != nil { - return err - } - } - return nil -} - -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of ArbitraryValue. -func (v *ArbitraryValue) MarshalLogObject(enc zapcore.ObjectEncoder) error { - if v.BoolValue != nil { - enc.AddBool("boolValue", *v.BoolValue) - } - if v.Int64Value != nil { - enc.AddInt64("int64Value", *v.Int64Value) - } - if v.StringValue != nil { - enc.AddString("stringValue", *v.StringValue) - } - if v.ListValue != nil { - if err := enc.AddArray("listValue", (_List_ArbitraryValue_Zapper)(v.ListValue)); err != nil { - return err - } - } - if v.MapValue != nil { - if err := enc.AddObject("mapValue", (_Map_String_ArbitraryValue_Zapper)(v.MapValue)); err != nil { - return err - } - } - - return nil -} - // GetBoolValue returns the value of BoolValue if it is set or its // zero value if it is unset. func (v *ArbitraryValue) GetBoolValue() (o bool) { @@ -705,19 +651,6 @@ func (v *Document) Equals(rhs *Document) bool { return true } -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of Document. -func (v *Document) MarshalLogObject(enc zapcore.ObjectEncoder) error { - if v.Pdf != nil { - enc.AddString("pdf", base64.StdEncoding.EncodeToString(([]byte)(v.Pdf))) - } - if v.PlainText != nil { - enc.AddString("plainText", *v.PlainText) - } - - return nil -} - // GetPdf returns the value of Pdf if it is set or its // zero value if it is unset. func (v *Document) GetPdf() (o typedefs.PDF) { @@ -813,10 +746,3 @@ func (v *EmptyUnion) Equals(rhs *EmptyUnion) bool { return true } - -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of EmptyUnion. -func (v *EmptyUnion) MarshalLogObject(enc zapcore.ObjectEncoder) error { - - return nil -} diff --git a/gen/enum.go b/gen/enum.go index 03470d60..fbca8449 100644 --- a/gen/enum.go +++ b/gen/enum.go @@ -125,23 +125,6 @@ func enum(g Generator, spec *compile.EnumSpec) error { return []byte(<$strconv>.FormatInt(int64(<$v>), 10)), nil } - <$zapcore := import "go.uber.org/zap/zapcore"> - - // MarshalLogObject implements zapcore.ObjectMarshaler, enabling - // fast logging of <$enumName>. - func (<$v> <$enumName>) MarshalLogObject(enc <$zapcore>.ObjectEncoder) error { - enc.AddInt32("value", int32(<$v>)) - - switch int32(<$v>) { - - case <.Value>: - enc.AddString("name", "<.Name>") - - } - - return nil - } - // Ptr returns a pointer to this enum value. func (<$v> <$enumName>) Ptr() *<$enumName> { return &<$v> diff --git a/gen/field.go b/gen/field.go index c51d07ee..c1a50367 100644 --- a/gen/field.go +++ b/gen/field.go @@ -1,4 +1,4 @@ -// Copyright (c) 2018 Uber Technologies, Inc +// Copyright (c) 2018 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 @@ -91,10 +91,6 @@ func (f fieldGroupGenerator) Generate(g Generator) error { return err } - if err := f.Zap(g); err != nil { - return err - } - return f.Accessors(g) } @@ -465,46 +461,6 @@ func (f fieldGroupGenerator) Equals(g Generator) error { `, f) } -func (f fieldGroupGenerator) Zap(g Generator) error { - return g.DeclareFromTemplate( - ` - <$zapcore := import "go.uber.org/zap/zapcore"> - <$v := newVar "v"> - <$enc := newVar "enc"> - - // MarshalLogObject implements zapcore.ObjectMarshaler, enabling - // fast logging of <.Name>. - func (<$v> *<.Name>) MarshalLogObject(<$enc> <$zapcore>.ObjectEncoder) error { - - <- $fname := goName . -> - <- $fval := printf "%s.%s" $v $fname -> - <- if .Required -> - <- $encAdd := printf "%s.Add%s(%q, %s)" $enc (zapEncoder .Type) .Name (zapMarshaler .Type $fval) -> - - if err := <$encAdd>; err != nil { - return err - } - <- else -> - <$encAdd> - <- end -> - <- else -> - <- $encAdd := printf "%s.Add%s(%q, %s)" $enc (zapEncoder .Type) .Name (zapMarshalerPtr .Type $fval) -> - if <$fval> != nil { - - if err := <$encAdd>; err != nil { - return err - } - <- else -> - <$encAdd> - <- end -> - } - <- end> - - return nil - } - `, f) -} - func (f fieldGroupGenerator) Accessors(g Generator) error { fieldsAndAccessors := NewNamespace() return g.DeclareFromTemplate( diff --git a/gen/generator.go b/gen/generator.go index f69ad2dc..fb70ee7e 100644 --- a/gen/generator.go +++ b/gen/generator.go @@ -128,7 +128,6 @@ type generator struct { w WireGenerator e equalsGenerator - z zapGenerator decls []ast.Decl thriftImporter ThriftPackageImporter mangler *mangler @@ -216,10 +215,6 @@ func (g *generator) TextTemplate(s string, data interface{}, opts ...TemplateOpt "typeCode": curryGenerator(TypeCode, g), "equals": curryGenerator(g.e.Equals, g), "equalsPtr": curryGenerator(g.e.EqualsPtr, g), - "zapCanError": g.z.zapCanError, - "zapEncoder": curryGenerator(g.z.zapEncoder, g), - "zapMarshaler": curryGenerator(g.z.zapMarshaler, g), - "zapMarshalerPtr": curryGenerator(g.z.zapMarshalerPtr, g), } tmpl := template.New("thriftrw").Delims("<", ">").Funcs(templateFuncs) diff --git a/gen/internal/tests/collision/types.go b/gen/internal/tests/collision/types.go index d5d440ac..84d02d06 100644 --- a/gen/internal/tests/collision/types.go +++ b/gen/internal/tests/collision/types.go @@ -9,7 +9,6 @@ import ( "errors" "fmt" "go.uber.org/thriftrw/wire" - "go.uber.org/zap/zapcore" "math" "strconv" "strings" @@ -157,19 +156,6 @@ func (v *AccessorConflict) Equals(rhs *AccessorConflict) bool { return true } -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of AccessorConflict. -func (v *AccessorConflict) MarshalLogObject(enc zapcore.ObjectEncoder) error { - if v.Name != nil { - enc.AddString("name", *v.Name) - } - if v.GetName2 != nil { - enc.AddString("get_name", *v.GetName2) - } - - return nil -} - // GetName returns the value of Name if it is set or its // zero value if it is unset. func (v *AccessorConflict) GetName() (o string) { @@ -322,19 +308,6 @@ func (v *AccessorNoConflict) Equals(rhs *AccessorNoConflict) bool { return true } -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of AccessorNoConflict. -func (v *AccessorNoConflict) MarshalLogObject(enc zapcore.ObjectEncoder) error { - if v.Getname != nil { - enc.AddString("getname", *v.Getname) - } - if v.GetName != nil { - enc.AddString("get_name", *v.GetName) - } - - return nil -} - // GetGetname returns the value of Getname if it is set or its // zero value if it is unset. func (v *AccessorNoConflict) GetGetname() (o string) { @@ -456,25 +429,6 @@ func (v MyEnum) MarshalText() ([]byte, error) { return []byte(strconv.FormatInt(int64(v), 10)), nil } -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of MyEnum. -func (v MyEnum) MarshalLogObject(enc zapcore.ObjectEncoder) error { - enc.AddInt32("value", int32(v)) - switch int32(v) { - case 123: - enc.AddString("name", "X") - case 456: - enc.AddString("name", "Y") - case 789: - enc.AddString("name", "Z") - case 790: - enc.AddString("name", "FooBar") - case 791: - enc.AddString("name", "foo_bar") - } - return nil -} - // Ptr returns a pointer to this enum value. func (v MyEnum) Ptr() *MyEnum { return &v @@ -939,61 +893,6 @@ func (v *PrimitiveContainers) Equals(rhs *PrimitiveContainers) bool { return true } -type _List_String_Zapper []string - -// MarshalLogArray implements zapcore.ArrayMarshaler, enabling -// fast logging of _List_String_Zapper. -func (l _List_String_Zapper) MarshalLogArray(enc zapcore.ArrayEncoder) error { - for _, v := range l { - enc.AppendString(v) - } - return nil -} - -type _Set_String_Zapper map[string]struct{} - -// MarshalLogArray implements zapcore.ArrayMarshaler, enabling -// fast logging of _Set_String_Zapper. -func (s _Set_String_Zapper) MarshalLogArray(enc zapcore.ArrayEncoder) error { - for v := range s { - enc.AppendString(v) - } - return nil -} - -type _Map_String_String_Zapper map[string]string - -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of _Map_String_String_Zapper. -func (m _Map_String_String_Zapper) MarshalLogObject(enc zapcore.ObjectEncoder) error { - for k, v := range m { - enc.AddString((string)(k), v) - } - return nil -} - -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of PrimitiveContainers. -func (v *PrimitiveContainers) MarshalLogObject(enc zapcore.ObjectEncoder) error { - if v.A != nil { - if err := enc.AddArray("ListOrSetOrMap", (_List_String_Zapper)(v.A)); err != nil { - return err - } - } - if v.B != nil { - if err := enc.AddArray("List_Or_SetOrMap", (_Set_String_Zapper)(v.B)); err != nil { - return err - } - } - if v.C != nil { - if err := enc.AddObject("ListOrSet_Or_Map", (_Map_String_String_Zapper)(v.C)); err != nil { - return err - } - } - - return nil -} - // GetA returns the value of A if it is set or its // zero value if it is unset. func (v *PrimitiveContainers) GetA() (o []string) { @@ -1156,15 +1055,6 @@ func (v *StructCollision) Equals(rhs *StructCollision) bool { return true } -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of StructCollision. -func (v *StructCollision) MarshalLogObject(enc zapcore.ObjectEncoder) error { - enc.AddBool("collisionField", v.CollisionField) - enc.AddString("collision_field", v.CollisionField2) - - return nil -} - // GetCollisionField returns the value of CollisionField if it is set or its // zero value if it is unset. func (v *StructCollision) GetCollisionField() (o bool) { return v.CollisionField } @@ -1330,19 +1220,6 @@ func (v *UnionCollision) Equals(rhs *UnionCollision) bool { return true } -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of UnionCollision. -func (v *UnionCollision) MarshalLogObject(enc zapcore.ObjectEncoder) error { - if v.CollisionField != nil { - enc.AddBool("collisionField", *v.CollisionField) - } - if v.CollisionField2 != nil { - enc.AddString("collision_field", *v.CollisionField2) - } - - return nil -} - // GetCollisionField returns the value of CollisionField if it is set or its // zero value if it is unset. func (v *UnionCollision) GetCollisionField() (o bool) { @@ -1486,18 +1363,6 @@ func (v *WithDefault) Equals(rhs *WithDefault) bool { return true } -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of WithDefault. -func (v *WithDefault) MarshalLogObject(enc zapcore.ObjectEncoder) error { - if v.Pouet != nil { - if err := enc.AddObject("pouet", v.Pouet); err != nil { - return err - } - } - - return nil -} - // GetPouet returns the value of Pouet if it is set or its // default value if it is unset. func (v *WithDefault) GetPouet() (o *StructCollision2) { @@ -1598,21 +1463,6 @@ func (v MyEnum2) MarshalText() ([]byte, error) { return []byte(strconv.FormatInt(int64(v), 10)), nil } -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of MyEnum2. -func (v MyEnum2) MarshalLogObject(enc zapcore.ObjectEncoder) error { - enc.AddInt32("value", int32(v)) - switch int32(v) { - case 12: - enc.AddString("name", "X") - case 34: - enc.AddString("name", "Y") - case 56: - enc.AddString("name", "Z") - } - return nil -} - // Ptr returns a pointer to this enum value. func (v MyEnum2) Ptr() *MyEnum2 { return &v @@ -1851,15 +1701,6 @@ func (v *StructCollision2) Equals(rhs *StructCollision2) bool { return true } -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of StructCollision2. -func (v *StructCollision2) MarshalLogObject(enc zapcore.ObjectEncoder) error { - enc.AddBool("collisionField", v.CollisionField) - enc.AddString("collision_field", v.CollisionField2) - - return nil -} - // GetCollisionField returns the value of CollisionField if it is set or its // zero value if it is unset. func (v *StructCollision2) GetCollisionField() (o bool) { return v.CollisionField } @@ -2015,19 +1856,6 @@ func (v *UnionCollision2) Equals(rhs *UnionCollision2) bool { return true } -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of UnionCollision2. -func (v *UnionCollision2) MarshalLogObject(enc zapcore.ObjectEncoder) error { - if v.CollisionField != nil { - enc.AddBool("collisionField", *v.CollisionField) - } - if v.CollisionField2 != nil { - enc.AddString("collision_field", *v.CollisionField2) - } - - return nil -} - // GetCollisionField returns the value of CollisionField if it is set or its // zero value if it is unset. func (v *UnionCollision2) GetCollisionField() (o bool) { diff --git a/gen/internal/tests/containers/types.go b/gen/internal/tests/containers/types.go index 53e2a135..1fec0906 100644 --- a/gen/internal/tests/containers/types.go +++ b/gen/internal/tests/containers/types.go @@ -5,7 +5,6 @@ package containers import ( "bytes" - "encoding/base64" "errors" "fmt" "go.uber.org/thriftrw/gen/internal/tests/enum_conflict" @@ -13,7 +12,6 @@ import ( "go.uber.org/thriftrw/gen/internal/tests/typedefs" "go.uber.org/thriftrw/gen/internal/tests/uuid_conflict" "go.uber.org/thriftrw/wire" - "go.uber.org/zap/zapcore" "strings" ) @@ -1654,353 +1652,6 @@ func (v *ContainersOfContainers) Equals(rhs *ContainersOfContainers) bool { return true } -type _List_I32_Zapper []int32 - -// MarshalLogArray implements zapcore.ArrayMarshaler, enabling -// fast logging of _List_I32_Zapper. -func (l _List_I32_Zapper) MarshalLogArray(enc zapcore.ArrayEncoder) error { - for _, v := range l { - enc.AppendInt32(v) - } - return nil -} - -type _List_List_I32_Zapper [][]int32 - -// MarshalLogArray implements zapcore.ArrayMarshaler, enabling -// fast logging of _List_List_I32_Zapper. -func (l _List_List_I32_Zapper) MarshalLogArray(enc zapcore.ArrayEncoder) error { - for _, v := range l { - if err := enc.AppendArray((_List_I32_Zapper)(v)); err != nil { - return err - } - } - return nil -} - -type _Set_I32_Zapper map[int32]struct{} - -// MarshalLogArray implements zapcore.ArrayMarshaler, enabling -// fast logging of _Set_I32_Zapper. -func (s _Set_I32_Zapper) MarshalLogArray(enc zapcore.ArrayEncoder) error { - for v := range s { - enc.AppendInt32(v) - } - return nil -} - -type _List_Set_I32_Zapper []map[int32]struct{} - -// MarshalLogArray implements zapcore.ArrayMarshaler, enabling -// fast logging of _List_Set_I32_Zapper. -func (l _List_Set_I32_Zapper) MarshalLogArray(enc zapcore.ArrayEncoder) error { - for _, v := range l { - if err := enc.AppendArray((_Set_I32_Zapper)(v)); err != nil { - return err - } - } - return nil -} - -type _MapItem_I32_I32_Zapper struct { - Key int32 - Value int32 -} - -// MarshalLogArray implements zapcore.ArrayMarshaler, enabling -// fast logging of _MapItem_I32_I32_Zapper. -func (v _MapItem_I32_I32_Zapper) MarshalLogObject(enc zapcore.ObjectEncoder) error { - enc.AddInt32("key", v.Key) - enc.AddInt32("value", v.Value) - return nil -} - -type _Map_I32_I32_Zapper map[int32]int32 - -// MarshalLogArray implements zapcore.ArrayMarshaler, enabling -// fast logging of _Map_I32_I32_Zapper. -func (m _Map_I32_I32_Zapper) MarshalLogArray(enc zapcore.ArrayEncoder) error { - for k, v := range m { - if err := enc.AppendObject(_MapItem_I32_I32_Zapper{Key: k, Value: v}); err != nil { - return err - } - } - return nil -} - -type _List_Map_I32_I32_Zapper []map[int32]int32 - -// MarshalLogArray implements zapcore.ArrayMarshaler, enabling -// fast logging of _List_Map_I32_I32_Zapper. -func (l _List_Map_I32_I32_Zapper) MarshalLogArray(enc zapcore.ArrayEncoder) error { - for _, v := range l { - if err := enc.AppendArray((_Map_I32_I32_Zapper)(v)); err != nil { - return err - } - } - return nil -} - -type _Set_String_Zapper map[string]struct{} - -// MarshalLogArray implements zapcore.ArrayMarshaler, enabling -// fast logging of _Set_String_Zapper. -func (s _Set_String_Zapper) MarshalLogArray(enc zapcore.ArrayEncoder) error { - for v := range s { - enc.AppendString(v) - } - return nil -} - -type _Set_Set_String_Zapper []map[string]struct{} - -// MarshalLogArray implements zapcore.ArrayMarshaler, enabling -// fast logging of _Set_Set_String_Zapper. -func (s _Set_Set_String_Zapper) MarshalLogArray(enc zapcore.ArrayEncoder) error { - for _, v := range s { - if err := enc.AppendArray((_Set_String_Zapper)(v)); err != nil { - return err - } - } - return nil -} - -type _List_String_Zapper []string - -// MarshalLogArray implements zapcore.ArrayMarshaler, enabling -// fast logging of _List_String_Zapper. -func (l _List_String_Zapper) MarshalLogArray(enc zapcore.ArrayEncoder) error { - for _, v := range l { - enc.AppendString(v) - } - return nil -} - -type _Set_List_String_Zapper [][]string - -// MarshalLogArray implements zapcore.ArrayMarshaler, enabling -// fast logging of _Set_List_String_Zapper. -func (s _Set_List_String_Zapper) MarshalLogArray(enc zapcore.ArrayEncoder) error { - for _, v := range s { - if err := enc.AppendArray((_List_String_Zapper)(v)); err != nil { - return err - } - } - return nil -} - -type _Map_String_String_Zapper map[string]string - -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of _Map_String_String_Zapper. -func (m _Map_String_String_Zapper) MarshalLogObject(enc zapcore.ObjectEncoder) error { - for k, v := range m { - enc.AddString((string)(k), v) - } - return nil -} - -type _Set_Map_String_String_Zapper []map[string]string - -// MarshalLogArray implements zapcore.ArrayMarshaler, enabling -// fast logging of _Set_Map_String_String_Zapper. -func (s _Set_Map_String_String_Zapper) MarshalLogArray(enc zapcore.ArrayEncoder) error { - for _, v := range s { - if err := enc.AppendObject((_Map_String_String_Zapper)(v)); err != nil { - return err - } - } - return nil -} - -type _Map_String_I32_Zapper map[string]int32 - -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of _Map_String_I32_Zapper. -func (m _Map_String_I32_Zapper) MarshalLogObject(enc zapcore.ObjectEncoder) error { - for k, v := range m { - enc.AddInt32((string)(k), v) - } - return nil -} - -type _MapItem_Map_String_I32_I64_Zapper struct { - Key map[string]int32 - Value int64 -} - -// MarshalLogArray implements zapcore.ArrayMarshaler, enabling -// fast logging of _MapItem_Map_String_I32_I64_Zapper. -func (v _MapItem_Map_String_I32_I64_Zapper) MarshalLogObject(enc zapcore.ObjectEncoder) error { - if err := enc.AddObject("key", (_Map_String_I32_Zapper)(v.Key)); err != nil { - return err - } - enc.AddInt64("value", v.Value) - return nil -} - -type _Map_Map_String_I32_I64_Zapper []struct { - Key map[string]int32 - Value int64 -} - -// MarshalLogArray implements zapcore.ArrayMarshaler, enabling -// fast logging of _Map_Map_String_I32_I64_Zapper. -func (m _Map_Map_String_I32_I64_Zapper) MarshalLogArray(enc zapcore.ArrayEncoder) error { - for _, i := range m { - k := i.Key - v := i.Value - if err := enc.AppendObject(_MapItem_Map_String_I32_I64_Zapper{Key: k, Value: v}); err != nil { - return err - } - } - return nil -} - -type _Set_I64_Zapper map[int64]struct{} - -// MarshalLogArray implements zapcore.ArrayMarshaler, enabling -// fast logging of _Set_I64_Zapper. -func (s _Set_I64_Zapper) MarshalLogArray(enc zapcore.ArrayEncoder) error { - for v := range s { - enc.AppendInt64(v) - } - return nil -} - -type _MapItem_List_I32_Set_I64_Zapper struct { - Key []int32 - Value map[int64]struct{} -} - -// MarshalLogArray implements zapcore.ArrayMarshaler, enabling -// fast logging of _MapItem_List_I32_Set_I64_Zapper. -func (v _MapItem_List_I32_Set_I64_Zapper) MarshalLogObject(enc zapcore.ObjectEncoder) error { - if err := enc.AddArray("key", (_List_I32_Zapper)(v.Key)); err != nil { - return err - } - if err := enc.AddArray("value", (_Set_I64_Zapper)(v.Value)); err != nil { - return err - } - return nil -} - -type _Map_List_I32_Set_I64_Zapper []struct { - Key []int32 - Value map[int64]struct{} -} - -// MarshalLogArray implements zapcore.ArrayMarshaler, enabling -// fast logging of _Map_List_I32_Set_I64_Zapper. -func (m _Map_List_I32_Set_I64_Zapper) MarshalLogArray(enc zapcore.ArrayEncoder) error { - for _, i := range m { - k := i.Key - v := i.Value - if err := enc.AppendObject(_MapItem_List_I32_Set_I64_Zapper{Key: k, Value: v}); err != nil { - return err - } - } - return nil -} - -type _List_Double_Zapper []float64 - -// MarshalLogArray implements zapcore.ArrayMarshaler, enabling -// fast logging of _List_Double_Zapper. -func (l _List_Double_Zapper) MarshalLogArray(enc zapcore.ArrayEncoder) error { - for _, v := range l { - enc.AppendFloat64(v) - } - return nil -} - -type _MapItem_Set_I32_List_Double_Zapper struct { - Key map[int32]struct{} - Value []float64 -} - -// MarshalLogArray implements zapcore.ArrayMarshaler, enabling -// fast logging of _MapItem_Set_I32_List_Double_Zapper. -func (v _MapItem_Set_I32_List_Double_Zapper) MarshalLogObject(enc zapcore.ObjectEncoder) error { - if err := enc.AddArray("key", (_Set_I32_Zapper)(v.Key)); err != nil { - return err - } - if err := enc.AddArray("value", (_List_Double_Zapper)(v.Value)); err != nil { - return err - } - return nil -} - -type _Map_Set_I32_List_Double_Zapper []struct { - Key map[int32]struct{} - Value []float64 -} - -// MarshalLogArray implements zapcore.ArrayMarshaler, enabling -// fast logging of _Map_Set_I32_List_Double_Zapper. -func (m _Map_Set_I32_List_Double_Zapper) MarshalLogArray(enc zapcore.ArrayEncoder) error { - for _, i := range m { - k := i.Key - v := i.Value - if err := enc.AppendObject(_MapItem_Set_I32_List_Double_Zapper{Key: k, Value: v}); err != nil { - return err - } - } - return nil -} - -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of ContainersOfContainers. -func (v *ContainersOfContainers) MarshalLogObject(enc zapcore.ObjectEncoder) error { - if v.ListOfLists != nil { - if err := enc.AddArray("listOfLists", (_List_List_I32_Zapper)(v.ListOfLists)); err != nil { - return err - } - } - if v.ListOfSets != nil { - if err := enc.AddArray("listOfSets", (_List_Set_I32_Zapper)(v.ListOfSets)); err != nil { - return err - } - } - if v.ListOfMaps != nil { - if err := enc.AddArray("listOfMaps", (_List_Map_I32_I32_Zapper)(v.ListOfMaps)); err != nil { - return err - } - } - if v.SetOfSets != nil { - if err := enc.AddArray("setOfSets", (_Set_Set_String_Zapper)(v.SetOfSets)); err != nil { - return err - } - } - if v.SetOfLists != nil { - if err := enc.AddArray("setOfLists", (_Set_List_String_Zapper)(v.SetOfLists)); err != nil { - return err - } - } - if v.SetOfMaps != nil { - if err := enc.AddArray("setOfMaps", (_Set_Map_String_String_Zapper)(v.SetOfMaps)); err != nil { - return err - } - } - if v.MapOfMapToInt != nil { - if err := enc.AddArray("mapOfMapToInt", (_Map_Map_String_I32_I64_Zapper)(v.MapOfMapToInt)); err != nil { - return err - } - } - if v.MapOfListToSet != nil { - if err := enc.AddArray("mapOfListToSet", (_Map_List_I32_Set_I64_Zapper)(v.MapOfListToSet)); err != nil { - return err - } - } - if v.MapOfSetToListOfDouble != nil { - if err := enc.AddArray("mapOfSetToListOfDouble", (_Map_Set_I32_List_Double_Zapper)(v.MapOfSetToListOfDouble)); err != nil { - return err - } - } - - return nil -} - // GetListOfLists returns the value of ListOfLists if it is set or its // zero value if it is unset. func (v *ContainersOfContainers) GetListOfLists() (o [][]int32) { @@ -2468,82 +2119,6 @@ func (v *EnumContainers) Equals(rhs *EnumContainers) bool { return true } -type _List_EnumDefault_Zapper []enums.EnumDefault - -// MarshalLogArray implements zapcore.ArrayMarshaler, enabling -// fast logging of _List_EnumDefault_Zapper. -func (l _List_EnumDefault_Zapper) MarshalLogArray(enc zapcore.ArrayEncoder) error { - for _, v := range l { - if err := enc.AppendObject(v); err != nil { - return err - } - } - return nil -} - -type _Set_EnumWithValues_Zapper map[enums.EnumWithValues]struct{} - -// MarshalLogArray implements zapcore.ArrayMarshaler, enabling -// fast logging of _Set_EnumWithValues_Zapper. -func (s _Set_EnumWithValues_Zapper) MarshalLogArray(enc zapcore.ArrayEncoder) error { - for v := range s { - if err := enc.AppendObject(v); err != nil { - return err - } - } - return nil -} - -type _MapItem_EnumWithDuplicateValues_I32_Zapper struct { - Key enums.EnumWithDuplicateValues - Value int32 -} - -// MarshalLogArray implements zapcore.ArrayMarshaler, enabling -// fast logging of _MapItem_EnumWithDuplicateValues_I32_Zapper. -func (v _MapItem_EnumWithDuplicateValues_I32_Zapper) MarshalLogObject(enc zapcore.ObjectEncoder) error { - if err := enc.AddObject("key", v.Key); err != nil { - return err - } - enc.AddInt32("value", v.Value) - return nil -} - -type _Map_EnumWithDuplicateValues_I32_Zapper map[enums.EnumWithDuplicateValues]int32 - -// MarshalLogArray implements zapcore.ArrayMarshaler, enabling -// fast logging of _Map_EnumWithDuplicateValues_I32_Zapper. -func (m _Map_EnumWithDuplicateValues_I32_Zapper) MarshalLogArray(enc zapcore.ArrayEncoder) error { - for k, v := range m { - if err := enc.AppendObject(_MapItem_EnumWithDuplicateValues_I32_Zapper{Key: k, Value: v}); err != nil { - return err - } - } - return nil -} - -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of EnumContainers. -func (v *EnumContainers) MarshalLogObject(enc zapcore.ObjectEncoder) error { - if v.ListOfEnums != nil { - if err := enc.AddArray("listOfEnums", (_List_EnumDefault_Zapper)(v.ListOfEnums)); err != nil { - return err - } - } - if v.SetOfEnums != nil { - if err := enc.AddArray("setOfEnums", (_Set_EnumWithValues_Zapper)(v.SetOfEnums)); err != nil { - return err - } - } - if v.MapOfEnums != nil { - if err := enc.AddArray("mapOfEnums", (_Map_EnumWithDuplicateValues_I32_Zapper)(v.MapOfEnums)); err != nil { - return err - } - } - - return nil -} - // GetListOfEnums returns the value of ListOfEnums if it is set or its // zero value if it is unset. func (v *EnumContainers) GetListOfEnums() (o []enums.EnumDefault) { @@ -2841,45 +2416,6 @@ func (v *ListOfConflictingEnums) Equals(rhs *ListOfConflictingEnums) bool { return true } -type _List_RecordType_Zapper []enum_conflict.RecordType - -// MarshalLogArray implements zapcore.ArrayMarshaler, enabling -// fast logging of _List_RecordType_Zapper. -func (l _List_RecordType_Zapper) MarshalLogArray(enc zapcore.ArrayEncoder) error { - for _, v := range l { - if err := enc.AppendObject(v); err != nil { - return err - } - } - return nil -} - -type _List_RecordType_1_Zapper []enums.RecordType - -// MarshalLogArray implements zapcore.ArrayMarshaler, enabling -// fast logging of _List_RecordType_1_Zapper. -func (l _List_RecordType_1_Zapper) MarshalLogArray(enc zapcore.ArrayEncoder) error { - for _, v := range l { - if err := enc.AppendObject(v); err != nil { - return err - } - } - return nil -} - -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of ListOfConflictingEnums. -func (v *ListOfConflictingEnums) MarshalLogObject(enc zapcore.ObjectEncoder) error { - if err := enc.AddArray("records", (_List_RecordType_Zapper)(v.Records)); err != nil { - return err - } - if err := enc.AddArray("otherRecords", (_List_RecordType_1_Zapper)(v.OtherRecords)); err != nil { - return err - } - - return nil -} - // GetRecords returns the value of Records if it is set or its // zero value if it is unset. func (v *ListOfConflictingEnums) GetRecords() (o []enum_conflict.RecordType) { return v.Records } @@ -3158,43 +2694,6 @@ func (v *ListOfConflictingUUIDs) Equals(rhs *ListOfConflictingUUIDs) bool { return true } -type _List_UUID_Zapper []*typedefs.UUID - -// MarshalLogArray implements zapcore.ArrayMarshaler, enabling -// fast logging of _List_UUID_Zapper. -func (l _List_UUID_Zapper) MarshalLogArray(enc zapcore.ArrayEncoder) error { - for _, v := range l { - if err := enc.AppendObject((*typedefs.I128)(v)); err != nil { - return err - } - } - return nil -} - -type _List_UUID_1_Zapper []uuid_conflict.UUID - -// MarshalLogArray implements zapcore.ArrayMarshaler, enabling -// fast logging of _List_UUID_1_Zapper. -func (l _List_UUID_1_Zapper) MarshalLogArray(enc zapcore.ArrayEncoder) error { - for _, v := range l { - enc.AppendString((string)(v)) - } - return nil -} - -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of ListOfConflictingUUIDs. -func (v *ListOfConflictingUUIDs) MarshalLogObject(enc zapcore.ObjectEncoder) error { - if err := enc.AddArray("uuids", (_List_UUID_Zapper)(v.Uuids)); err != nil { - return err - } - if err := enc.AddArray("otherUUIDs", (_List_UUID_1_Zapper)(v.OtherUUIDs)); err != nil { - return err - } - - return nil -} - // GetUuids returns the value of Uuids if it is set or its // zero value if it is unset. func (v *ListOfConflictingUUIDs) GetUuids() (o []*typedefs.UUID) { return v.Uuids } @@ -3530,65 +3029,6 @@ func (v *MapOfBinaryAndString) Equals(rhs *MapOfBinaryAndString) bool { return true } -type _MapItem_Binary_String_Zapper struct { - Key []byte - Value string -} - -// MarshalLogArray implements zapcore.ArrayMarshaler, enabling -// fast logging of _MapItem_Binary_String_Zapper. -func (v _MapItem_Binary_String_Zapper) MarshalLogObject(enc zapcore.ObjectEncoder) error { - enc.AddString("key", base64.StdEncoding.EncodeToString(v.Key)) - enc.AddString("value", v.Value) - return nil -} - -type _Map_Binary_String_Zapper []struct { - Key []byte - Value string -} - -// MarshalLogArray implements zapcore.ArrayMarshaler, enabling -// fast logging of _Map_Binary_String_Zapper. -func (m _Map_Binary_String_Zapper) MarshalLogArray(enc zapcore.ArrayEncoder) error { - for _, i := range m { - k := i.Key - v := i.Value - if err := enc.AppendObject(_MapItem_Binary_String_Zapper{Key: k, Value: v}); err != nil { - return err - } - } - return nil -} - -type _Map_String_Binary_Zapper map[string][]byte - -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of _Map_String_Binary_Zapper. -func (m _Map_String_Binary_Zapper) MarshalLogObject(enc zapcore.ObjectEncoder) error { - for k, v := range m { - enc.AddString((string)(k), base64.StdEncoding.EncodeToString(v)) - } - return nil -} - -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of MapOfBinaryAndString. -func (v *MapOfBinaryAndString) MarshalLogObject(enc zapcore.ObjectEncoder) error { - if v.BinaryToString != nil { - if err := enc.AddArray("binaryToString", (_Map_Binary_String_Zapper)(v.BinaryToString)); err != nil { - return err - } - } - if v.StringToBinary != nil { - if err := enc.AddObject("stringToBinary", (_Map_String_Binary_Zapper)(v.StringToBinary)); err != nil { - return err - } - } - - return nil -} - // GetBinaryToString returns the value of BinaryToString if it is set or its // zero value if it is unset. func (v *MapOfBinaryAndString) GetBinaryToString() (o []struct { @@ -4176,113 +3616,6 @@ func (v *PrimitiveContainers) Equals(rhs *PrimitiveContainers) bool { return true } -type _List_Binary_Zapper [][]byte - -// MarshalLogArray implements zapcore.ArrayMarshaler, enabling -// fast logging of _List_Binary_Zapper. -func (l _List_Binary_Zapper) MarshalLogArray(enc zapcore.ArrayEncoder) error { - for _, v := range l { - enc.AppendString(base64.StdEncoding.EncodeToString(v)) - } - return nil -} - -type _List_I64_Zapper []int64 - -// MarshalLogArray implements zapcore.ArrayMarshaler, enabling -// fast logging of _List_I64_Zapper. -func (l _List_I64_Zapper) MarshalLogArray(enc zapcore.ArrayEncoder) error { - for _, v := range l { - enc.AppendInt64(v) - } - return nil -} - -type _Set_Byte_Zapper map[int8]struct{} - -// MarshalLogArray implements zapcore.ArrayMarshaler, enabling -// fast logging of _Set_Byte_Zapper. -func (s _Set_Byte_Zapper) MarshalLogArray(enc zapcore.ArrayEncoder) error { - for v := range s { - enc.AppendInt8(v) - } - return nil -} - -type _MapItem_I32_String_Zapper struct { - Key int32 - Value string -} - -// MarshalLogArray implements zapcore.ArrayMarshaler, enabling -// fast logging of _MapItem_I32_String_Zapper. -func (v _MapItem_I32_String_Zapper) MarshalLogObject(enc zapcore.ObjectEncoder) error { - enc.AddInt32("key", v.Key) - enc.AddString("value", v.Value) - return nil -} - -type _Map_I32_String_Zapper map[int32]string - -// MarshalLogArray implements zapcore.ArrayMarshaler, enabling -// fast logging of _Map_I32_String_Zapper. -func (m _Map_I32_String_Zapper) MarshalLogArray(enc zapcore.ArrayEncoder) error { - for k, v := range m { - if err := enc.AppendObject(_MapItem_I32_String_Zapper{Key: k, Value: v}); err != nil { - return err - } - } - return nil -} - -type _Map_String_Bool_Zapper map[string]bool - -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of _Map_String_Bool_Zapper. -func (m _Map_String_Bool_Zapper) MarshalLogObject(enc zapcore.ObjectEncoder) error { - for k, v := range m { - enc.AddBool((string)(k), v) - } - return nil -} - -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of PrimitiveContainers. -func (v *PrimitiveContainers) MarshalLogObject(enc zapcore.ObjectEncoder) error { - if v.ListOfBinary != nil { - if err := enc.AddArray("listOfBinary", (_List_Binary_Zapper)(v.ListOfBinary)); err != nil { - return err - } - } - if v.ListOfInts != nil { - if err := enc.AddArray("listOfInts", (_List_I64_Zapper)(v.ListOfInts)); err != nil { - return err - } - } - if v.SetOfStrings != nil { - if err := enc.AddArray("setOfStrings", (_Set_String_Zapper)(v.SetOfStrings)); err != nil { - return err - } - } - if v.SetOfBytes != nil { - if err := enc.AddArray("setOfBytes", (_Set_Byte_Zapper)(v.SetOfBytes)); err != nil { - return err - } - } - if v.MapOfIntToString != nil { - if err := enc.AddArray("mapOfIntToString", (_Map_I32_String_Zapper)(v.MapOfIntToString)); err != nil { - return err - } - } - if v.MapOfStringToBool != nil { - if err := enc.AddObject("mapOfStringToBool", (_Map_String_Bool_Zapper)(v.MapOfStringToBool)); err != nil { - return err - } - } - - return nil -} - // GetListOfBinary returns the value of ListOfBinary if it is set or its // zero value if it is unset. func (v *PrimitiveContainers) GetListOfBinary() (o [][]byte) { @@ -4588,48 +3921,6 @@ func (v *PrimitiveContainersRequired) Equals(rhs *PrimitiveContainersRequired) b return true } -type _MapItem_I64_Double_Zapper struct { - Key int64 - Value float64 -} - -// MarshalLogArray implements zapcore.ArrayMarshaler, enabling -// fast logging of _MapItem_I64_Double_Zapper. -func (v _MapItem_I64_Double_Zapper) MarshalLogObject(enc zapcore.ObjectEncoder) error { - enc.AddInt64("key", v.Key) - enc.AddFloat64("value", v.Value) - return nil -} - -type _Map_I64_Double_Zapper map[int64]float64 - -// MarshalLogArray implements zapcore.ArrayMarshaler, enabling -// fast logging of _Map_I64_Double_Zapper. -func (m _Map_I64_Double_Zapper) MarshalLogArray(enc zapcore.ArrayEncoder) error { - for k, v := range m { - if err := enc.AppendObject(_MapItem_I64_Double_Zapper{Key: k, Value: v}); err != nil { - return err - } - } - return nil -} - -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of PrimitiveContainersRequired. -func (v *PrimitiveContainersRequired) MarshalLogObject(enc zapcore.ObjectEncoder) error { - if err := enc.AddArray("listOfStrings", (_List_String_Zapper)(v.ListOfStrings)); err != nil { - return err - } - if err := enc.AddArray("setOfInts", (_Set_I32_Zapper)(v.SetOfInts)); err != nil { - return err - } - if err := enc.AddArray("mapOfIntsToDoubles", (_Map_I64_Double_Zapper)(v.MapOfIntsToDoubles)); err != nil { - return err - } - - return nil -} - // GetListOfStrings returns the value of ListOfStrings if it is set or its // zero value if it is unset. func (v *PrimitiveContainersRequired) GetListOfStrings() (o []string) { return v.ListOfStrings } diff --git a/gen/internal/tests/enum_conflict/types.go b/gen/internal/tests/enum_conflict/types.go index 5e76e9e5..ecd10d2b 100644 --- a/gen/internal/tests/enum_conflict/types.go +++ b/gen/internal/tests/enum_conflict/types.go @@ -9,7 +9,6 @@ import ( "fmt" "go.uber.org/thriftrw/gen/internal/tests/enums" "go.uber.org/thriftrw/wire" - "go.uber.org/zap/zapcore" "math" "strconv" "strings" @@ -64,19 +63,6 @@ func (v RecordType) MarshalText() ([]byte, error) { return []byte(strconv.FormatInt(int64(v), 10)), nil } -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of RecordType. -func (v RecordType) MarshalLogObject(enc zapcore.ObjectEncoder) error { - enc.AddInt32("value", int32(v)) - switch int32(v) { - case 0: - enc.AddString("name", "Name") - case 1: - enc.AddString("name", "Email") - } - return nil -} - // Ptr returns a pointer to this enum value. func (v RecordType) Ptr() *RecordType { return &v @@ -365,23 +351,6 @@ func (v *Records) Equals(rhs *Records) bool { return true } -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of Records. -func (v *Records) MarshalLogObject(enc zapcore.ObjectEncoder) error { - if v.RecordType != nil { - if err := enc.AddObject("recordType", *v.RecordType); err != nil { - return err - } - } - if v.OtherRecordType != nil { - if err := enc.AddObject("otherRecordType", *v.OtherRecordType); err != nil { - return err - } - } - - return nil -} - // GetRecordType returns the value of RecordType if it is set or its // default value if it is unset. func (v *Records) GetRecordType() (o RecordType) { diff --git a/gen/internal/tests/enums/types.go b/gen/internal/tests/enums/types.go index 3ef66a48..bd2c7650 100644 --- a/gen/internal/tests/enums/types.go +++ b/gen/internal/tests/enums/types.go @@ -8,7 +8,6 @@ import ( "encoding/json" "fmt" "go.uber.org/thriftrw/wire" - "go.uber.org/zap/zapcore" "math" "strconv" "strings" @@ -35,13 +34,6 @@ func (v EmptyEnum) MarshalText() ([]byte, error) { return []byte(strconv.FormatInt(int64(v), 10)), nil } -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of EmptyEnum. -func (v EmptyEnum) MarshalLogObject(enc zapcore.ObjectEncoder) error { - enc.AddInt32("value", int32(v)) - return nil -} - // Ptr returns a pointer to this enum value. func (v EmptyEnum) Ptr() *EmptyEnum { return &v @@ -188,21 +180,6 @@ func (v EnumDefault) MarshalText() ([]byte, error) { return []byte(strconv.FormatInt(int64(v), 10)), nil } -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of EnumDefault. -func (v EnumDefault) MarshalLogObject(enc zapcore.ObjectEncoder) error { - enc.AddInt32("value", int32(v)) - switch int32(v) { - case 0: - enc.AddString("name", "Foo") - case 1: - enc.AddString("name", "Bar") - case 2: - enc.AddString("name", "Baz") - } - return nil -} - // Ptr returns a pointer to this enum value. func (v EnumDefault) Ptr() *EnumDefault { return &v @@ -407,33 +384,6 @@ func (v EnumWithDuplicateName) MarshalText() ([]byte, error) { return []byte(strconv.FormatInt(int64(v), 10)), nil } -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of EnumWithDuplicateName. -func (v EnumWithDuplicateName) MarshalLogObject(enc zapcore.ObjectEncoder) error { - enc.AddInt32("value", int32(v)) - switch int32(v) { - case 0: - enc.AddString("name", "A") - case 1: - enc.AddString("name", "B") - case 2: - enc.AddString("name", "C") - case 3: - enc.AddString("name", "P") - case 4: - enc.AddString("name", "Q") - case 5: - enc.AddString("name", "R") - case 6: - enc.AddString("name", "X") - case 7: - enc.AddString("name", "Y") - case 8: - enc.AddString("name", "Z") - } - return nil -} - // Ptr returns a pointer to this enum value. func (v EnumWithDuplicateName) Ptr() *EnumWithDuplicateName { return &v @@ -618,19 +568,6 @@ func (v EnumWithDuplicateValues) MarshalText() ([]byte, error) { return []byte(strconv.FormatInt(int64(v), 10)), nil } -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of EnumWithDuplicateValues. -func (v EnumWithDuplicateValues) MarshalLogObject(enc zapcore.ObjectEncoder) error { - enc.AddInt32("value", int32(v)) - switch int32(v) { - case 0: - enc.AddString("name", "P") - case -1: - enc.AddString("name", "Q") - } - return nil -} - // Ptr returns a pointer to this enum value. func (v EnumWithDuplicateValues) Ptr() *EnumWithDuplicateValues { return &v @@ -789,21 +726,6 @@ func (v EnumWithValues) MarshalText() ([]byte, error) { return []byte(strconv.FormatInt(int64(v), 10)), nil } -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of EnumWithValues. -func (v EnumWithValues) MarshalLogObject(enc zapcore.ObjectEncoder) error { - enc.AddInt32("value", int32(v)) - switch int32(v) { - case 123: - enc.AddString("name", "X") - case 456: - enc.AddString("name", "Y") - case 789: - enc.AddString("name", "Z") - } - return nil -} - // Ptr returns a pointer to this enum value. func (v EnumWithValues) Ptr() *EnumWithValues { return &v @@ -974,21 +896,6 @@ func (v RecordType) MarshalText() ([]byte, error) { return []byte(strconv.FormatInt(int64(v), 10)), nil } -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of RecordType. -func (v RecordType) MarshalLogObject(enc zapcore.ObjectEncoder) error { - enc.AddInt32("value", int32(v)) - switch int32(v) { - case 0: - enc.AddString("name", "NAME") - case 1: - enc.AddString("name", "HOME_ADDRESS") - case 2: - enc.AddString("name", "WORK_ADDRESS") - } - return nil -} - // Ptr returns a pointer to this enum value. func (v RecordType) Ptr() *RecordType { return &v @@ -1144,19 +1051,6 @@ func (v RecordTypeValues) MarshalText() ([]byte, error) { return []byte(strconv.FormatInt(int64(v), 10)), nil } -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of RecordTypeValues. -func (v RecordTypeValues) MarshalLogObject(enc zapcore.ObjectEncoder) error { - enc.AddInt32("value", int32(v)) - switch int32(v) { - case 0: - enc.AddString("name", "FOO") - case 1: - enc.AddString("name", "BAR") - } - return nil -} - // Ptr returns a pointer to this enum value. func (v RecordTypeValues) Ptr() *RecordTypeValues { return &v @@ -1381,18 +1275,6 @@ func (v *StructWithOptionalEnum) Equals(rhs *StructWithOptionalEnum) bool { return true } -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of StructWithOptionalEnum. -func (v *StructWithOptionalEnum) MarshalLogObject(enc zapcore.ObjectEncoder) error { - if v.E != nil { - if err := enc.AddObject("e", *v.E); err != nil { - return err - } - } - - return nil -} - // GetE returns the value of E if it is set or its // zero value if it is unset. func (v *StructWithOptionalEnum) GetE() (o EnumDefault) { @@ -1459,21 +1341,6 @@ func (v LowerCaseEnum) MarshalText() ([]byte, error) { return []byte(strconv.FormatInt(int64(v), 10)), nil } -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of LowerCaseEnum. -func (v LowerCaseEnum) MarshalLogObject(enc zapcore.ObjectEncoder) error { - enc.AddInt32("value", int32(v)) - switch int32(v) { - case 0: - enc.AddString("name", "containing") - case 1: - enc.AddString("name", "lower_case") - case 2: - enc.AddString("name", "items") - } - return nil -} - // Ptr returns a pointer to this enum value. func (v LowerCaseEnum) Ptr() *LowerCaseEnum { return &v diff --git a/gen/internal/tests/exceptions/types.go b/gen/internal/tests/exceptions/types.go index 0e16a2f4..973600ca 100644 --- a/gen/internal/tests/exceptions/types.go +++ b/gen/internal/tests/exceptions/types.go @@ -7,7 +7,6 @@ import ( "errors" "fmt" "go.uber.org/thriftrw/wire" - "go.uber.org/zap/zapcore" "strings" ) @@ -155,17 +154,6 @@ func (v *DoesNotExistException) Equals(rhs *DoesNotExistException) bool { return true } -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of DoesNotExistException. -func (v *DoesNotExistException) MarshalLogObject(enc zapcore.ObjectEncoder) error { - enc.AddString("key", v.Key) - if v.Error2 != nil { - enc.AddString("Error", *v.Error2) - } - - return nil -} - // GetKey returns the value of Key if it is set or its // zero value if it is unset. func (v *DoesNotExistException) GetKey() (o string) { return v.Key } @@ -260,13 +248,6 @@ func (v *EmptyException) Equals(rhs *EmptyException) bool { return true } -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of EmptyException. -func (v *EmptyException) MarshalLogObject(enc zapcore.ObjectEncoder) error { - - return nil -} - func (v *EmptyException) Error() string { return v.String() } diff --git a/gen/internal/tests/services/cache_clear.go b/gen/internal/tests/services/cache_clear.go index 15470b9c..b502d4cb 100644 --- a/gen/internal/tests/services/cache_clear.go +++ b/gen/internal/tests/services/cache_clear.go @@ -6,7 +6,6 @@ package services import ( "fmt" "go.uber.org/thriftrw/wire" - "go.uber.org/zap/zapcore" "strings" ) @@ -89,13 +88,6 @@ func (v *Cache_Clear_Args) Equals(rhs *Cache_Clear_Args) bool { return true } -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of Cache_Clear_Args. -func (v *Cache_Clear_Args) MarshalLogObject(enc zapcore.ObjectEncoder) error { - - return nil -} - // MethodName returns the name of the Thrift function as specified in // the IDL, for which this struct represent the arguments. // diff --git a/gen/internal/tests/services/cache_clearafter.go b/gen/internal/tests/services/cache_clearafter.go index 0a840c5a..8f2e912a 100644 --- a/gen/internal/tests/services/cache_clearafter.go +++ b/gen/internal/tests/services/cache_clearafter.go @@ -6,7 +6,6 @@ package services import ( "fmt" "go.uber.org/thriftrw/wire" - "go.uber.org/zap/zapcore" "strings" ) @@ -129,16 +128,6 @@ func (v *Cache_ClearAfter_Args) Equals(rhs *Cache_ClearAfter_Args) bool { return true } -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of Cache_ClearAfter_Args. -func (v *Cache_ClearAfter_Args) MarshalLogObject(enc zapcore.ObjectEncoder) error { - if v.DurationMS != nil { - enc.AddInt64("durationMS", *v.DurationMS) - } - - return nil -} - // GetDurationMS returns the value of DurationMS if it is set or its // zero value if it is unset. func (v *Cache_ClearAfter_Args) GetDurationMS() (o int64) { diff --git a/gen/internal/tests/services/conflictingnames_setvalue.go b/gen/internal/tests/services/conflictingnames_setvalue.go index 3aa348a2..b77f78e9 100644 --- a/gen/internal/tests/services/conflictingnames_setvalue.go +++ b/gen/internal/tests/services/conflictingnames_setvalue.go @@ -6,7 +6,6 @@ package services import ( "fmt" "go.uber.org/thriftrw/wire" - "go.uber.org/zap/zapcore" "strings" ) @@ -123,18 +122,6 @@ func (v *ConflictingNames_SetValue_Args) Equals(rhs *ConflictingNames_SetValue_A return true } -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of ConflictingNames_SetValue_Args. -func (v *ConflictingNames_SetValue_Args) MarshalLogObject(enc zapcore.ObjectEncoder) error { - if v.Request != nil { - if err := enc.AddObject("request", v.Request); err != nil { - return err - } - } - - return nil -} - // GetRequest returns the value of Request if it is set or its // zero value if it is unset. func (v *ConflictingNames_SetValue_Args) GetRequest() (o *ConflictingNamesSetValueArgs) { @@ -314,13 +301,6 @@ func (v *ConflictingNames_SetValue_Result) Equals(rhs *ConflictingNames_SetValue return true } -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of ConflictingNames_SetValue_Result. -func (v *ConflictingNames_SetValue_Result) MarshalLogObject(enc zapcore.ObjectEncoder) error { - - return nil -} - // MethodName returns the name of the Thrift function as specified in // the IDL, for which this struct represent the result. // diff --git a/gen/internal/tests/services/keyvalue_deletevalue.go b/gen/internal/tests/services/keyvalue_deletevalue.go index d27f6293..55d6dad6 100644 --- a/gen/internal/tests/services/keyvalue_deletevalue.go +++ b/gen/internal/tests/services/keyvalue_deletevalue.go @@ -8,7 +8,6 @@ import ( "fmt" "go.uber.org/thriftrw/gen/internal/tests/exceptions" "go.uber.org/thriftrw/wire" - "go.uber.org/zap/zapcore" "strings" ) @@ -137,16 +136,6 @@ func (v *KeyValue_DeleteValue_Args) Equals(rhs *KeyValue_DeleteValue_Args) bool return true } -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of KeyValue_DeleteValue_Args. -func (v *KeyValue_DeleteValue_Args) MarshalLogObject(enc zapcore.ObjectEncoder) error { - if v.Key != nil { - enc.AddString("key", (string)(*v.Key)) - } - - return nil -} - // GetKey returns the value of Key if it is set or its // zero value if it is unset. func (v *KeyValue_DeleteValue_Args) GetKey() (o Key) { @@ -431,23 +420,6 @@ func (v *KeyValue_DeleteValue_Result) Equals(rhs *KeyValue_DeleteValue_Result) b return true } -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of KeyValue_DeleteValue_Result. -func (v *KeyValue_DeleteValue_Result) MarshalLogObject(enc zapcore.ObjectEncoder) error { - if v.DoesNotExist != nil { - if err := enc.AddObject("doesNotExist", v.DoesNotExist); err != nil { - return err - } - } - if v.InternalError != nil { - if err := enc.AddObject("internalError", v.InternalError); err != nil { - return err - } - } - - return nil -} - // GetDoesNotExist returns the value of DoesNotExist if it is set or its // zero value if it is unset. func (v *KeyValue_DeleteValue_Result) GetDoesNotExist() (o *exceptions.DoesNotExistException) { diff --git a/gen/internal/tests/services/keyvalue_getmanyvalues.go b/gen/internal/tests/services/keyvalue_getmanyvalues.go index 5408bc6d..8a73ecc8 100644 --- a/gen/internal/tests/services/keyvalue_getmanyvalues.go +++ b/gen/internal/tests/services/keyvalue_getmanyvalues.go @@ -9,7 +9,6 @@ import ( "go.uber.org/thriftrw/gen/internal/tests/exceptions" "go.uber.org/thriftrw/gen/internal/tests/unions" "go.uber.org/thriftrw/wire" - "go.uber.org/zap/zapcore" "strings" ) @@ -179,29 +178,6 @@ func (v *KeyValue_GetManyValues_Args) Equals(rhs *KeyValue_GetManyValues_Args) b return true } -type _List_Key_Zapper []Key - -// MarshalLogArray implements zapcore.ArrayMarshaler, enabling -// fast logging of _List_Key_Zapper. -func (l _List_Key_Zapper) MarshalLogArray(enc zapcore.ArrayEncoder) error { - for _, v := range l { - enc.AppendString((string)(v)) - } - return nil -} - -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of KeyValue_GetManyValues_Args. -func (v *KeyValue_GetManyValues_Args) MarshalLogObject(enc zapcore.ObjectEncoder) error { - if v.Range != nil { - if err := enc.AddArray("range", (_List_Key_Zapper)(v.Range)); err != nil { - return err - } - } - - return nil -} - // GetRange returns the value of Range if it is set or its // zero value if it is unset. func (v *KeyValue_GetManyValues_Args) GetRange() (o []Key) { @@ -539,36 +515,6 @@ func (v *KeyValue_GetManyValues_Result) Equals(rhs *KeyValue_GetManyValues_Resul return true } -type _List_ArbitraryValue_Zapper []*unions.ArbitraryValue - -// MarshalLogArray implements zapcore.ArrayMarshaler, enabling -// fast logging of _List_ArbitraryValue_Zapper. -func (l _List_ArbitraryValue_Zapper) MarshalLogArray(enc zapcore.ArrayEncoder) error { - for _, v := range l { - if err := enc.AppendObject(v); err != nil { - return err - } - } - return nil -} - -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of KeyValue_GetManyValues_Result. -func (v *KeyValue_GetManyValues_Result) MarshalLogObject(enc zapcore.ObjectEncoder) error { - if v.Success != nil { - if err := enc.AddArray("success", (_List_ArbitraryValue_Zapper)(v.Success)); err != nil { - return err - } - } - if v.DoesNotExist != nil { - if err := enc.AddObject("doesNotExist", v.DoesNotExist); err != nil { - return err - } - } - - return nil -} - // GetSuccess returns the value of Success if it is set or its // zero value if it is unset. func (v *KeyValue_GetManyValues_Result) GetSuccess() (o []*unions.ArbitraryValue) { diff --git a/gen/internal/tests/services/keyvalue_getvalue.go b/gen/internal/tests/services/keyvalue_getvalue.go index ae23f608..aa10142c 100644 --- a/gen/internal/tests/services/keyvalue_getvalue.go +++ b/gen/internal/tests/services/keyvalue_getvalue.go @@ -9,7 +9,6 @@ import ( "go.uber.org/thriftrw/gen/internal/tests/exceptions" "go.uber.org/thriftrw/gen/internal/tests/unions" "go.uber.org/thriftrw/wire" - "go.uber.org/zap/zapcore" "strings" ) @@ -122,16 +121,6 @@ func (v *KeyValue_GetValue_Args) Equals(rhs *KeyValue_GetValue_Args) bool { return true } -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of KeyValue_GetValue_Args. -func (v *KeyValue_GetValue_Args) MarshalLogObject(enc zapcore.ObjectEncoder) error { - if v.Key != nil { - enc.AddString("key", (string)(*v.Key)) - } - - return nil -} - // GetKey returns the value of Key if it is set or its // zero value if it is unset. func (v *KeyValue_GetValue_Args) GetKey() (o Key) { @@ -401,23 +390,6 @@ func (v *KeyValue_GetValue_Result) Equals(rhs *KeyValue_GetValue_Result) bool { return true } -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of KeyValue_GetValue_Result. -func (v *KeyValue_GetValue_Result) MarshalLogObject(enc zapcore.ObjectEncoder) error { - if v.Success != nil { - if err := enc.AddObject("success", v.Success); err != nil { - return err - } - } - if v.DoesNotExist != nil { - if err := enc.AddObject("doesNotExist", v.DoesNotExist); err != nil { - return err - } - } - - return nil -} - // GetSuccess returns the value of Success if it is set or its // zero value if it is unset. func (v *KeyValue_GetValue_Result) GetSuccess() (o *unions.ArbitraryValue) { diff --git a/gen/internal/tests/services/keyvalue_setvalue.go b/gen/internal/tests/services/keyvalue_setvalue.go index 2b5b0a15..95cb424a 100644 --- a/gen/internal/tests/services/keyvalue_setvalue.go +++ b/gen/internal/tests/services/keyvalue_setvalue.go @@ -7,7 +7,6 @@ import ( "fmt" "go.uber.org/thriftrw/gen/internal/tests/unions" "go.uber.org/thriftrw/wire" - "go.uber.org/zap/zapcore" "strings" ) @@ -144,21 +143,6 @@ func (v *KeyValue_SetValue_Args) Equals(rhs *KeyValue_SetValue_Args) bool { return true } -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of KeyValue_SetValue_Args. -func (v *KeyValue_SetValue_Args) MarshalLogObject(enc zapcore.ObjectEncoder) error { - if v.Key != nil { - enc.AddString("key", (string)(*v.Key)) - } - if v.Value != nil { - if err := enc.AddObject("value", v.Value); err != nil { - return err - } - } - - return nil -} - // GetKey returns the value of Key if it is set or its // zero value if it is unset. func (v *KeyValue_SetValue_Args) GetKey() (o Key) { @@ -351,13 +335,6 @@ func (v *KeyValue_SetValue_Result) Equals(rhs *KeyValue_SetValue_Result) bool { return true } -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of KeyValue_SetValue_Result. -func (v *KeyValue_SetValue_Result) MarshalLogObject(enc zapcore.ObjectEncoder) error { - - return nil -} - // MethodName returns the name of the Thrift function as specified in // the IDL, for which this struct represent the result. // diff --git a/gen/internal/tests/services/keyvalue_setvaluev2.go b/gen/internal/tests/services/keyvalue_setvaluev2.go index 1cad6f78..a2fb7009 100644 --- a/gen/internal/tests/services/keyvalue_setvaluev2.go +++ b/gen/internal/tests/services/keyvalue_setvaluev2.go @@ -8,7 +8,6 @@ import ( "fmt" "go.uber.org/thriftrw/gen/internal/tests/unions" "go.uber.org/thriftrw/wire" - "go.uber.org/zap/zapcore" "strings" ) @@ -153,17 +152,6 @@ func (v *KeyValue_SetValueV2_Args) Equals(rhs *KeyValue_SetValueV2_Args) bool { return true } -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of KeyValue_SetValueV2_Args. -func (v *KeyValue_SetValueV2_Args) MarshalLogObject(enc zapcore.ObjectEncoder) error { - enc.AddString("key", (string)(v.Key)) - if err := enc.AddObject("value", v.Value); err != nil { - return err - } - - return nil -} - // GetKey returns the value of Key if it is set or its // zero value if it is unset. func (v *KeyValue_SetValueV2_Args) GetKey() (o Key) { return v.Key } @@ -344,13 +332,6 @@ func (v *KeyValue_SetValueV2_Result) Equals(rhs *KeyValue_SetValueV2_Result) boo return true } -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of KeyValue_SetValueV2_Result. -func (v *KeyValue_SetValueV2_Result) MarshalLogObject(enc zapcore.ObjectEncoder) error { - - return nil -} - // MethodName returns the name of the Thrift function as specified in // the IDL, for which this struct represent the result. // diff --git a/gen/internal/tests/services/keyvalue_size.go b/gen/internal/tests/services/keyvalue_size.go index fa5ccf3c..228e98e3 100644 --- a/gen/internal/tests/services/keyvalue_size.go +++ b/gen/internal/tests/services/keyvalue_size.go @@ -7,7 +7,6 @@ import ( "errors" "fmt" "go.uber.org/thriftrw/wire" - "go.uber.org/zap/zapcore" "strings" ) @@ -90,13 +89,6 @@ func (v *KeyValue_Size_Args) Equals(rhs *KeyValue_Size_Args) bool { return true } -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of KeyValue_Size_Args. -func (v *KeyValue_Size_Args) MarshalLogObject(enc zapcore.ObjectEncoder) error { - - return nil -} - // MethodName returns the name of the Thrift function as specified in // the IDL, for which this struct represent the arguments. // @@ -311,16 +303,6 @@ func (v *KeyValue_Size_Result) Equals(rhs *KeyValue_Size_Result) bool { return true } -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of KeyValue_Size_Result. -func (v *KeyValue_Size_Result) MarshalLogObject(enc zapcore.ObjectEncoder) error { - if v.Success != nil { - enc.AddInt64("success", *v.Success) - } - - return nil -} - // GetSuccess returns the value of Success if it is set or its // zero value if it is unset. func (v *KeyValue_Size_Result) GetSuccess() (o int64) { diff --git a/gen/internal/tests/services/non_standard_service_name_non_standard_function_name.go b/gen/internal/tests/services/non_standard_service_name_non_standard_function_name.go index 37c15fb3..840613ad 100644 --- a/gen/internal/tests/services/non_standard_service_name_non_standard_function_name.go +++ b/gen/internal/tests/services/non_standard_service_name_non_standard_function_name.go @@ -6,7 +6,6 @@ package services import ( "fmt" "go.uber.org/thriftrw/wire" - "go.uber.org/zap/zapcore" "strings" ) @@ -89,13 +88,6 @@ func (v *NonStandardServiceName_NonStandardFunctionName_Args) Equals(rhs *NonSta return true } -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of NonStandardServiceName_NonStandardFunctionName_Args. -func (v *NonStandardServiceName_NonStandardFunctionName_Args) MarshalLogObject(enc zapcore.ObjectEncoder) error { - - return nil -} - // MethodName returns the name of the Thrift function as specified in // the IDL, for which this struct represent the arguments. // @@ -259,13 +251,6 @@ func (v *NonStandardServiceName_NonStandardFunctionName_Result) Equals(rhs *NonS return true } -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of NonStandardServiceName_NonStandardFunctionName_Result. -func (v *NonStandardServiceName_NonStandardFunctionName_Result) MarshalLogObject(enc zapcore.ObjectEncoder) error { - - return nil -} - // MethodName returns the name of the Thrift function as specified in // the IDL, for which this struct represent the result. // diff --git a/gen/internal/tests/services/types.go b/gen/internal/tests/services/types.go index b785dba5..c17c1ed3 100644 --- a/gen/internal/tests/services/types.go +++ b/gen/internal/tests/services/types.go @@ -5,11 +5,9 @@ package services import ( "bytes" - "encoding/base64" "errors" "fmt" "go.uber.org/thriftrw/wire" - "go.uber.org/zap/zapcore" "strings" ) @@ -147,15 +145,6 @@ func (v *ConflictingNamesSetValueArgs) Equals(rhs *ConflictingNamesSetValueArgs) return true } -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of ConflictingNamesSetValueArgs. -func (v *ConflictingNamesSetValueArgs) MarshalLogObject(enc zapcore.ObjectEncoder) error { - enc.AddString("key", v.Key) - enc.AddString("value", base64.StdEncoding.EncodeToString(v.Value)) - - return nil -} - // GetKey returns the value of Key if it is set or its // zero value if it is unset. func (v *ConflictingNamesSetValueArgs) GetKey() (o string) { return v.Key } @@ -280,16 +269,6 @@ func (v *InternalError) Equals(rhs *InternalError) bool { return true } -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of InternalError. -func (v *InternalError) MarshalLogObject(enc zapcore.ObjectEncoder) error { - if v.Message != nil { - enc.AddString("message", *v.Message) - } - - return nil -} - // GetMessage returns the value of Message if it is set or its // zero value if it is unset. func (v *InternalError) GetMessage() (o string) { diff --git a/gen/internal/tests/structs/types.go b/gen/internal/tests/structs/types.go index c4a0ddc5..361ef83b 100644 --- a/gen/internal/tests/structs/types.go +++ b/gen/internal/tests/structs/types.go @@ -5,13 +5,11 @@ package structs import ( "bytes" - "encoding/base64" "errors" "fmt" "go.uber.org/thriftrw/gen/internal/tests/enums" "go.uber.org/thriftrw/ptr" "go.uber.org/thriftrw/wire" - "go.uber.org/zap/zapcore" "strings" ) @@ -121,14 +119,6 @@ func (v *ContactInfo) Equals(rhs *ContactInfo) bool { return true } -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of ContactInfo. -func (v *ContactInfo) MarshalLogObject(enc zapcore.ObjectEncoder) error { - enc.AddString("emailAddress", v.EmailAddress) - - return nil -} - // GetEmailAddress returns the value of EmailAddress if it is set or its // zero value if it is unset. func (v *ContactInfo) GetEmailAddress() (o string) { return v.EmailAddress } @@ -679,71 +669,6 @@ func (v *DefaultsStruct) Equals(rhs *DefaultsStruct) bool { return true } -type _List_String_Zapper []string - -// MarshalLogArray implements zapcore.ArrayMarshaler, enabling -// fast logging of _List_String_Zapper. -func (l _List_String_Zapper) MarshalLogArray(enc zapcore.ArrayEncoder) error { - for _, v := range l { - enc.AppendString(v) - } - return nil -} - -type _List_Double_Zapper []float64 - -// MarshalLogArray implements zapcore.ArrayMarshaler, enabling -// fast logging of _List_Double_Zapper. -func (l _List_Double_Zapper) MarshalLogArray(enc zapcore.ArrayEncoder) error { - for _, v := range l { - enc.AppendFloat64(v) - } - return nil -} - -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of DefaultsStruct. -func (v *DefaultsStruct) MarshalLogObject(enc zapcore.ObjectEncoder) error { - if v.RequiredPrimitive != nil { - enc.AddInt32("requiredPrimitive", *v.RequiredPrimitive) - } - if v.OptionalPrimitive != nil { - enc.AddInt32("optionalPrimitive", *v.OptionalPrimitive) - } - if v.RequiredEnum != nil { - if err := enc.AddObject("requiredEnum", *v.RequiredEnum); err != nil { - return err - } - } - if v.OptionalEnum != nil { - if err := enc.AddObject("optionalEnum", *v.OptionalEnum); err != nil { - return err - } - } - if v.RequiredList != nil { - if err := enc.AddArray("requiredList", (_List_String_Zapper)(v.RequiredList)); err != nil { - return err - } - } - if v.OptionalList != nil { - if err := enc.AddArray("optionalList", (_List_Double_Zapper)(v.OptionalList)); err != nil { - return err - } - } - if v.RequiredStruct != nil { - if err := enc.AddObject("requiredStruct", v.RequiredStruct); err != nil { - return err - } - } - if v.OptionalStruct != nil { - if err := enc.AddObject("optionalStruct", v.OptionalStruct); err != nil { - return err - } - } - - return nil -} - // GetRequiredPrimitive returns the value of RequiredPrimitive if it is set or its // default value if it is unset. func (v *DefaultsStruct) GetRequiredPrimitive() (o int32) { @@ -992,19 +917,6 @@ func (v *Edge) Equals(rhs *Edge) bool { return true } -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of Edge. -func (v *Edge) MarshalLogObject(enc zapcore.ObjectEncoder) error { - if err := enc.AddObject("startPoint", v.StartPoint); err != nil { - return err - } - if err := enc.AddObject("endPoint", v.EndPoint); err != nil { - return err - } - - return nil -} - // GetStartPoint returns the value of StartPoint if it is set or its // zero value if it is unset. func (v *Edge) GetStartPoint() (o *Point) { return v.StartPoint } @@ -1089,13 +1001,6 @@ func (v *EmptyStruct) Equals(rhs *EmptyStruct) bool { return true } -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of EmptyStruct. -func (v *EmptyStruct) MarshalLogObject(enc zapcore.ObjectEncoder) error { - - return nil -} - type Frame struct { TopLeft *Point `json:"topLeft,required"` Size *Size `json:"size,required"` @@ -1239,19 +1144,6 @@ func (v *Frame) Equals(rhs *Frame) bool { return true } -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of Frame. -func (v *Frame) MarshalLogObject(enc zapcore.ObjectEncoder) error { - if err := enc.AddObject("topLeft", v.TopLeft); err != nil { - return err - } - if err := enc.AddObject("size", v.Size); err != nil { - return err - } - - return nil -} - // GetTopLeft returns the value of TopLeft if it is set or its // zero value if it is unset. func (v *Frame) GetTopLeft() (o *Point) { return v.TopLeft } @@ -1508,23 +1400,6 @@ func (v *GoTags) Equals(rhs *GoTags) bool { return true } -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of GoTags. -func (v *GoTags) MarshalLogObject(enc zapcore.ObjectEncoder) error { - enc.AddString("Foo", v.Foo) - if v.Bar != nil { - enc.AddString("Bar", *v.Bar) - } - enc.AddString("FooBar", v.FooBar) - enc.AddString("FooBarWithSpace", v.FooBarWithSpace) - if v.FooBarWithOmitEmpty != nil { - enc.AddString("FooBarWithOmitEmpty", *v.FooBarWithOmitEmpty) - } - enc.AddString("FooBarWithRequired", v.FooBarWithRequired) - - return nil -} - // GetFoo returns the value of Foo if it is set or its // zero value if it is unset. func (v *GoTags) GetFoo() (o string) { return v.Foo } @@ -1736,29 +1611,6 @@ func (v *Graph) Equals(rhs *Graph) bool { return true } -type _List_Edge_Zapper []*Edge - -// MarshalLogArray implements zapcore.ArrayMarshaler, enabling -// fast logging of _List_Edge_Zapper. -func (l _List_Edge_Zapper) MarshalLogArray(enc zapcore.ArrayEncoder) error { - for _, v := range l { - if err := enc.AppendObject(v); err != nil { - return err - } - } - return nil -} - -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of Graph. -func (v *Graph) MarshalLogObject(enc zapcore.ObjectEncoder) error { - if err := enc.AddArray("edges", (_List_Edge_Zapper)(v.Edges)); err != nil { - return err - } - - return nil -} - // GetEdges returns the value of Edges if it is set or its // zero value if it is unset. func (v *Graph) GetEdges() (o []*Edge) { return v.Edges } @@ -1792,10 +1644,6 @@ func (lhs *List) Equals(rhs *List) bool { return (*Node)(lhs).Equals((*Node)(rhs)) } -func (v *List) MarshalLogObject(enc zapcore.ObjectEncoder) error { - return ((*Node)(v)).MarshalLogObject(enc) -} - // Node is linked list of values. // All values are 32-bit integers. type Node struct { @@ -1934,19 +1782,6 @@ func (v *Node) Equals(rhs *Node) bool { return true } -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of Node. -func (v *Node) MarshalLogObject(enc zapcore.ObjectEncoder) error { - enc.AddInt32("value", v.Value) - if v.Tail != nil { - if err := enc.AddObject("tail", (*Node)(v.Tail)); err != nil { - return err - } - } - - return nil -} - // GetValue returns the value of Value if it is set or its // zero value if it is unset. func (v *Node) GetValue() (o int32) { return v.Value } @@ -2093,15 +1928,6 @@ func (v *Omit) Equals(rhs *Omit) bool { return true } -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of Omit. -func (v *Omit) MarshalLogObject(enc zapcore.ObjectEncoder) error { - enc.AddString("serialized", v.Serialized) - enc.AddString("hidden", v.Hidden) - - return nil -} - // GetSerialized returns the value of Serialized if it is set or its // zero value if it is unset. func (v *Omit) GetSerialized() (o string) { return v.Serialized } @@ -2243,15 +2069,6 @@ func (v *Point) Equals(rhs *Point) bool { return true } -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of Point. -func (v *Point) MarshalLogObject(enc zapcore.ObjectEncoder) error { - enc.AddFloat64("x", v.X) - enc.AddFloat64("y", v.Y) - - return nil -} - // GetX returns the value of X if it is set or its // zero value if it is unset. func (v *Point) GetX() (o float64) { return v.X } @@ -2599,37 +2416,6 @@ func (v *PrimitiveOptionalStruct) Equals(rhs *PrimitiveOptionalStruct) bool { return true } -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of PrimitiveOptionalStruct. -func (v *PrimitiveOptionalStruct) MarshalLogObject(enc zapcore.ObjectEncoder) error { - if v.BoolField != nil { - enc.AddBool("boolField", *v.BoolField) - } - if v.ByteField != nil { - enc.AddInt8("byteField", *v.ByteField) - } - if v.Int16Field != nil { - enc.AddInt16("int16Field", *v.Int16Field) - } - if v.Int32Field != nil { - enc.AddInt32("int32Field", *v.Int32Field) - } - if v.Int64Field != nil { - enc.AddInt64("int64Field", *v.Int64Field) - } - if v.DoubleField != nil { - enc.AddFloat64("doubleField", *v.DoubleField) - } - if v.StringField != nil { - enc.AddString("stringField", *v.StringField) - } - if v.BinaryField != nil { - enc.AddString("binaryField", base64.StdEncoding.EncodeToString(v.BinaryField)) - } - - return nil -} - // GetBoolField returns the value of BoolField if it is set or its // zero value if it is unset. func (v *PrimitiveOptionalStruct) GetBoolField() (o bool) { @@ -3003,21 +2789,6 @@ func (v *PrimitiveRequiredStruct) Equals(rhs *PrimitiveRequiredStruct) bool { return true } -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of PrimitiveRequiredStruct. -func (v *PrimitiveRequiredStruct) MarshalLogObject(enc zapcore.ObjectEncoder) error { - enc.AddBool("boolField", v.BoolField) - enc.AddInt8("byteField", v.ByteField) - enc.AddInt16("int16Field", v.Int16Field) - enc.AddInt32("int32Field", v.Int32Field) - enc.AddInt64("int64Field", v.Int64Field) - enc.AddFloat64("doubleField", v.DoubleField) - enc.AddString("stringField", v.StringField) - enc.AddString("binaryField", base64.StdEncoding.EncodeToString(v.BinaryField)) - - return nil -} - // GetBoolField returns the value of BoolField if it is set or its // zero value if it is unset. func (v *PrimitiveRequiredStruct) GetBoolField() (o bool) { return v.BoolField } @@ -3182,15 +2953,6 @@ func (v *Rename) Equals(rhs *Rename) bool { return true } -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of Rename. -func (v *Rename) MarshalLogObject(enc zapcore.ObjectEncoder) error { - enc.AddString("Default", v.Default) - enc.AddString("camelCase", v.CamelCase) - - return nil -} - // GetDefault returns the value of Default if it is set or its // zero value if it is unset. func (v *Rename) GetDefault() (o string) { return v.Default } @@ -3334,15 +3096,6 @@ func (v *Size) Equals(rhs *Size) bool { return true } -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of Size. -func (v *Size) MarshalLogObject(enc zapcore.ObjectEncoder) error { - enc.AddFloat64("width", v.Width) - enc.AddFloat64("height", v.Height) - - return nil -} - // GetWidth returns the value of Width if it is set or its // zero value if it is unset. func (v *Size) GetWidth() (o float64) { return v.Width } @@ -3487,19 +3240,6 @@ func (v *User) Equals(rhs *User) bool { return true } -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of User. -func (v *User) MarshalLogObject(enc zapcore.ObjectEncoder) error { - enc.AddString("name", v.Name) - if v.Contact != nil { - if err := enc.AddObject("contact", v.Contact); err != nil { - return err - } - } - - return nil -} - // GetName returns the value of Name if it is set or its // zero value if it is unset. func (v *User) GetName() (o string) { return v.Name } diff --git a/gen/internal/tests/typedefs/types.go b/gen/internal/tests/typedefs/types.go index 5ac5612e..126784d2 100644 --- a/gen/internal/tests/typedefs/types.go +++ b/gen/internal/tests/typedefs/types.go @@ -5,13 +5,11 @@ package typedefs import ( "bytes" - "encoding/base64" "errors" "fmt" "go.uber.org/thriftrw/gen/internal/tests/enums" "go.uber.org/thriftrw/gen/internal/tests/structs" "go.uber.org/thriftrw/wire" - "go.uber.org/zap/zapcore" "strings" ) @@ -84,17 +82,6 @@ func _Set_Binary_Equals(lhs, rhs [][]byte) bool { return true } -type _BinarySet_Zapper [][]byte - -// MarshalLogArray implements zapcore.ArrayMarshaler, enabling -// fast logging of _BinarySet_Zapper. -func (s _BinarySet_Zapper) MarshalLogArray(enc zapcore.ArrayEncoder) error { - for _, v := range s { - enc.AppendString(base64.StdEncoding.EncodeToString(v)) - } - return nil -} - type BinarySet [][]byte // ToWire translates BinarySet into a Thrift-level intermediate @@ -126,10 +113,6 @@ func (lhs BinarySet) Equals(rhs BinarySet) bool { return _Set_Binary_Equals(lhs, rhs) } -func (v BinarySet) MarshalLogArray(enc zapcore.ArrayEncoder) error { - return ((_BinarySet_Zapper)(([][]byte)(v))).MarshalLogArray(enc) -} - type DefaultPrimitiveTypedef struct { State *State `json:"state,omitempty"` } @@ -263,16 +246,6 @@ func (v *DefaultPrimitiveTypedef) Equals(rhs *DefaultPrimitiveTypedef) bool { return true } -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of DefaultPrimitiveTypedef. -func (v *DefaultPrimitiveTypedef) MarshalLogObject(enc zapcore.ObjectEncoder) error { - if v.State != nil { - enc.AddString("state", (string)(*v.State)) - } - - return nil -} - // GetState returns the value of State if it is set or its // default value if it is unset. func (v *DefaultPrimitiveTypedef) GetState() (o State) { @@ -405,41 +378,6 @@ func _Map_Edge_Edge_Equals(lhs, rhs []struct { return true } -type _MapItem_Edge_Edge_Zapper struct { - Key *structs.Edge - Value *structs.Edge -} - -// MarshalLogArray implements zapcore.ArrayMarshaler, enabling -// fast logging of _MapItem_Edge_Edge_Zapper. -func (v _MapItem_Edge_Edge_Zapper) MarshalLogObject(enc zapcore.ObjectEncoder) error { - if err := enc.AddObject("key", v.Key); err != nil { - return err - } - if err := enc.AddObject("value", v.Value); err != nil { - return err - } - return nil -} - -type _EdgeMap_Zapper []struct { - Key *structs.Edge - Value *structs.Edge -} - -// MarshalLogArray implements zapcore.ArrayMarshaler, enabling -// fast logging of _EdgeMap_Zapper. -func (m _EdgeMap_Zapper) MarshalLogArray(enc zapcore.ArrayEncoder) error { - for _, i := range m { - k := i.Key - v := i.Value - if err := enc.AppendObject(_MapItem_Edge_Edge_Zapper{Key: k, Value: v}); err != nil { - return err - } - } - return nil -} - type EdgeMap []struct { Key *structs.Edge Value *structs.Edge @@ -480,13 +418,6 @@ func (lhs EdgeMap) Equals(rhs EdgeMap) bool { return _Map_Edge_Edge_Equals(lhs, rhs) } -func (v EdgeMap) MarshalLogArray(enc zapcore.ArrayEncoder) error { - return ((_EdgeMap_Zapper)(([]struct { - Key *structs.Edge - Value *structs.Edge - })(v))).MarshalLogArray(enc) -} - type Event struct { UUID *UUID `json:"uuid,required"` Time *Timestamp `json:"time,omitempty"` @@ -644,19 +575,6 @@ func (v *Event) Equals(rhs *Event) bool { return true } -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of Event. -func (v *Event) MarshalLogObject(enc zapcore.ObjectEncoder) error { - if err := enc.AddObject("uuid", (*I128)(v.UUID)); err != nil { - return err - } - if v.Time != nil { - enc.AddInt64("time", (int64)(*v.Time)) - } - - return nil -} - // GetUUID returns the value of UUID if it is set or its // zero value if it is unset. func (v *Event) GetUUID() (o *UUID) { return v.UUID } @@ -739,19 +657,6 @@ func _List_Event_Equals(lhs, rhs []*Event) bool { return true } -type _EventGroup_Zapper []*Event - -// MarshalLogArray implements zapcore.ArrayMarshaler, enabling -// fast logging of _EventGroup_Zapper. -func (l _EventGroup_Zapper) MarshalLogArray(enc zapcore.ArrayEncoder) error { - for _, v := range l { - if err := enc.AppendObject(v); err != nil { - return err - } - } - return nil -} - type EventGroup []*Event // ToWire translates EventGroup into a Thrift-level intermediate @@ -783,10 +688,6 @@ func (lhs EventGroup) Equals(rhs EventGroup) bool { return _List_Event_Equals(lhs, rhs) } -func (v EventGroup) MarshalLogArray(enc zapcore.ArrayEncoder) error { - return ((_EventGroup_Zapper)(([]*Event)(v))).MarshalLogArray(enc) -} - type _Set_Frame_ValueList []*structs.Frame func (v _Set_Frame_ValueList) ForEach(f func(wire.Value) error) error { @@ -862,19 +763,6 @@ func _Set_Frame_Equals(lhs, rhs []*structs.Frame) bool { return true } -type _FrameGroup_Zapper []*structs.Frame - -// MarshalLogArray implements zapcore.ArrayMarshaler, enabling -// fast logging of _FrameGroup_Zapper. -func (s _FrameGroup_Zapper) MarshalLogArray(enc zapcore.ArrayEncoder) error { - for _, v := range s { - if err := enc.AppendObject(v); err != nil { - return err - } - } - return nil -} - type FrameGroup []*structs.Frame // ToWire translates FrameGroup into a Thrift-level intermediate @@ -906,10 +794,6 @@ func (lhs FrameGroup) Equals(rhs FrameGroup) bool { return _Set_Frame_Equals(lhs, rhs) } -func (v FrameGroup) MarshalLogArray(enc zapcore.ArrayEncoder) error { - return ((_FrameGroup_Zapper)(([]*structs.Frame)(v))).MarshalLogArray(enc) -} - func _EnumWithValues_Read(w wire.Value) (enums.EnumWithValues, error) { var v enums.EnumWithValues err := v.FromWire(w) @@ -947,10 +831,6 @@ func (lhs MyEnum) Equals(rhs MyEnum) bool { return lhs.Equals(rhs) } -func (v MyEnum) MarshalLogObject(enc zapcore.ObjectEncoder) error { - return ((enums.EnumWithValues)(v)).MarshalLogObject(enc) -} - type PDF []byte // ToWire translates PDF into a Thrift-level intermediate @@ -1104,41 +984,6 @@ func _Map_Point_Point_Equals(lhs, rhs []struct { return true } -type _MapItem_Point_Point_Zapper struct { - Key *structs.Point - Value *structs.Point -} - -// MarshalLogArray implements zapcore.ArrayMarshaler, enabling -// fast logging of _MapItem_Point_Point_Zapper. -func (v _MapItem_Point_Point_Zapper) MarshalLogObject(enc zapcore.ObjectEncoder) error { - if err := enc.AddObject("key", v.Key); err != nil { - return err - } - if err := enc.AddObject("value", v.Value); err != nil { - return err - } - return nil -} - -type _PointMap_Zapper []struct { - Key *structs.Point - Value *structs.Point -} - -// MarshalLogArray implements zapcore.ArrayMarshaler, enabling -// fast logging of _PointMap_Zapper. -func (m _PointMap_Zapper) MarshalLogArray(enc zapcore.ArrayEncoder) error { - for _, i := range m { - k := i.Key - v := i.Value - if err := enc.AppendObject(_MapItem_Point_Point_Zapper{Key: k, Value: v}); err != nil { - return err - } - } - return nil -} - type PointMap []struct { Key *structs.Point Value *structs.Point @@ -1179,13 +1024,6 @@ func (lhs PointMap) Equals(rhs PointMap) bool { return _Map_Point_Point_Equals(lhs, rhs) } -func (v PointMap) MarshalLogArray(enc zapcore.ArrayEncoder) error { - return ((_PointMap_Zapper)(([]struct { - Key *structs.Point - Value *structs.Point - })(v))).MarshalLogArray(enc) -} - type State string // ToWire translates State into a Thrift-level intermediate @@ -1413,20 +1251,6 @@ func (v *Transition) Equals(rhs *Transition) bool { return true } -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of Transition. -func (v *Transition) MarshalLogObject(enc zapcore.ObjectEncoder) error { - enc.AddString("fromState", (string)(v.FromState)) - enc.AddString("toState", (string)(v.ToState)) - if v.Events != nil { - if err := enc.AddArray("events", (_EventGroup_Zapper)(([]*Event)(v.Events))); err != nil { - return err - } - } - - return nil -} - // GetFromState returns the value of FromState if it is set or its // zero value if it is unset. func (v *Transition) GetFromState() (o State) { return v.FromState } @@ -1474,10 +1298,6 @@ func (lhs *UUID) Equals(rhs *UUID) bool { return (*I128)(lhs).Equals((*I128)(rhs)) } -func (v *UUID) MarshalLogObject(enc zapcore.ObjectEncoder) error { - return ((*I128)(v)).MarshalLogObject(enc) -} - type I128 struct { High int64 `json:"high,required"` Low int64 `json:"low,required"` @@ -1610,15 +1430,6 @@ func (v *I128) Equals(rhs *I128) bool { return true } -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of I128. -func (v *I128) MarshalLogObject(enc zapcore.ObjectEncoder) error { - enc.AddInt64("high", v.High) - enc.AddInt64("low", v.Low) - - return nil -} - // GetHigh returns the value of High if it is set or its // zero value if it is unset. func (v *I128) GetHigh() (o int64) { return v.High } diff --git a/gen/internal/tests/unions/types.go b/gen/internal/tests/unions/types.go index 38485d67..2ff8d95b 100644 --- a/gen/internal/tests/unions/types.go +++ b/gen/internal/tests/unions/types.go @@ -4,11 +4,9 @@ package unions import ( - "encoding/base64" "fmt" "go.uber.org/thriftrw/gen/internal/tests/typedefs" "go.uber.org/thriftrw/wire" - "go.uber.org/zap/zapcore" "strings" ) @@ -432,58 +430,6 @@ func (v *ArbitraryValue) Equals(rhs *ArbitraryValue) bool { return true } -type _List_ArbitraryValue_Zapper []*ArbitraryValue - -// MarshalLogArray implements zapcore.ArrayMarshaler, enabling -// fast logging of _List_ArbitraryValue_Zapper. -func (l _List_ArbitraryValue_Zapper) MarshalLogArray(enc zapcore.ArrayEncoder) error { - for _, v := range l { - if err := enc.AppendObject(v); err != nil { - return err - } - } - return nil -} - -type _Map_String_ArbitraryValue_Zapper map[string]*ArbitraryValue - -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of _Map_String_ArbitraryValue_Zapper. -func (m _Map_String_ArbitraryValue_Zapper) MarshalLogObject(enc zapcore.ObjectEncoder) error { - for k, v := range m { - if err := enc.AddObject((string)(k), v); err != nil { - return err - } - } - return nil -} - -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of ArbitraryValue. -func (v *ArbitraryValue) MarshalLogObject(enc zapcore.ObjectEncoder) error { - if v.BoolValue != nil { - enc.AddBool("boolValue", *v.BoolValue) - } - if v.Int64Value != nil { - enc.AddInt64("int64Value", *v.Int64Value) - } - if v.StringValue != nil { - enc.AddString("stringValue", *v.StringValue) - } - if v.ListValue != nil { - if err := enc.AddArray("listValue", (_List_ArbitraryValue_Zapper)(v.ListValue)); err != nil { - return err - } - } - if v.MapValue != nil { - if err := enc.AddObject("mapValue", (_Map_String_ArbitraryValue_Zapper)(v.MapValue)); err != nil { - return err - } - } - - return nil -} - // GetBoolValue returns the value of BoolValue if it is set or its // zero value if it is unset. func (v *ArbitraryValue) GetBoolValue() (o bool) { @@ -685,19 +631,6 @@ func (v *Document) Equals(rhs *Document) bool { return true } -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of Document. -func (v *Document) MarshalLogObject(enc zapcore.ObjectEncoder) error { - if v.Pdf != nil { - enc.AddString("pdf", base64.StdEncoding.EncodeToString(([]byte)(v.Pdf))) - } - if v.PlainText != nil { - enc.AddString("plainText", *v.PlainText) - } - - return nil -} - // GetPdf returns the value of Pdf if it is set or its // zero value if it is unset. func (v *Document) GetPdf() (o typedefs.PDF) { @@ -793,10 +726,3 @@ func (v *EmptyUnion) Equals(rhs *EmptyUnion) bool { return true } - -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of EmptyUnion. -func (v *EmptyUnion) MarshalLogObject(enc zapcore.ObjectEncoder) error { - - return nil -} diff --git a/gen/internal/tests/uuid_conflict/types.go b/gen/internal/tests/uuid_conflict/types.go index bb44bd3a..cd64697e 100644 --- a/gen/internal/tests/uuid_conflict/types.go +++ b/gen/internal/tests/uuid_conflict/types.go @@ -8,7 +8,6 @@ import ( "fmt" "go.uber.org/thriftrw/gen/internal/tests/typedefs" "go.uber.org/thriftrw/wire" - "go.uber.org/zap/zapcore" "strings" ) @@ -189,17 +188,6 @@ func (v *UUIDConflict) Equals(rhs *UUIDConflict) bool { return true } -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of UUIDConflict. -func (v *UUIDConflict) MarshalLogObject(enc zapcore.ObjectEncoder) error { - enc.AddString("localUUID", (string)(v.LocalUUID)) - if err := enc.AddObject("importedUUID", (*typedefs.I128)(v.ImportedUUID)); err != nil { - return err - } - - return nil -} - // GetLocalUUID returns the value of LocalUUID if it is set or its // zero value if it is unset. func (v *UUIDConflict) GetLocalUUID() (o UUID) { return v.LocalUUID } diff --git a/gen/list.go b/gen/list.go index 715f44b4..bac379d0 100644 --- a/gen/list.go +++ b/gen/list.go @@ -20,11 +20,7 @@ package gen -import ( - "fmt" - - "go.uber.org/thriftrw/compile" -) +import "go.uber.org/thriftrw/compile" // listGenerator generates logic to convert lists of arbitrary Thrift types to // and from ValueLists. @@ -181,45 +177,3 @@ func (l *listGenerator) Equals(g Generator, spec *compile.ListSpec) (string, err return name, wrapGenerateError(spec.ThriftName(), err) } - -func (l *listGenerator) zapMarshaler( - g Generator, - spec compile.TypeSpec, - root *compile.ListSpec, - fieldValue string, -) (string, error) { - name := zapperName(g, spec) - if err := g.EnsureDeclared( - ` - type <.Name> - <$zapcore := import "go.uber.org/zap/zapcore"> - <$l := newVar "l"> - <$v := newVar "v"> - <$enc := newVar "enc"> - // MarshalLogArray implements zapcore.ArrayMarshaler, enabling - // fast logging of <.Name>. - func (<$l> <.Name>) MarshalLogArray(<$enc> <$zapcore>.ArrayEncoder) error { - for _, <$v> := range <$l> { - <- $encAppend := printf "%s.Append%s(%s)" $enc (zapEncoder .Type.ValueSpec) (zapMarshaler .Type.ValueSpec $v)> - - if err := <$encAppend>; err != nil { - return err - } - <- else -> - <$encAppend> - <- end> - } - return nil - } - `, struct { - Name string - Type *compile.ListSpec - }{ - Name: name, - Type: root, - }, - ); err != nil { - return "", err - } - return fmt.Sprintf("(%v)(%v)", name, fieldValue), nil -} diff --git a/gen/map.go b/gen/map.go index 9dd57e78..d901b815 100644 --- a/gen/map.go +++ b/gen/map.go @@ -281,144 +281,3 @@ func (m *mapGenerator) equalsUnhashable(g Generator, spec *compile.MapSpec) (str return name, wrapGenerateError(spec.ThriftName(), err) } - -func (m *mapGenerator) zapMarshaler( - g Generator, - spec compile.TypeSpec, - root *compile.MapSpec, - fieldValue string, -) (string, error) { - name := zapperName(g, spec) - switch root.KeySpec.(type) { - case *compile.StringSpec: - // We are already at the root, so no need to check if it is a typedef of a - // string. For simplicity, we always cast the key to a string when logging this way. - if err := g.EnsureDeclared( - ` - type <.Name> - <$zapcore := import "go.uber.org/zap/zapcore"> - <$m := newVar "m"> - <$k := newVar "k"> - <$v := newVar "v"> - <$enc := newVar "enc"> - // MarshalLogObject implements zapcore.ObjectMarshaler, enabling - // fast logging of <.Name>. - func (<$m> <.Name>) MarshalLogObject(<$enc> <$zapcore>.ObjectEncoder) error { - for <$k>, <$v> := range <$m> { - <- $encAdd := printf "%s.Add%s((string)(%s), %s)" $enc (zapEncoder .Type.ValueSpec) $k (zapMarshaler .Type.ValueSpec $v)> - - if err := <$encAdd>; err != nil { - return err - } - <- else -> - <$encAdd> - <- end> - } - return nil - } - `, struct { - Name string - Type *compile.MapSpec - }{ - Name: name, - Type: root, - }, - ); err != nil { - return "", err - } - return fmt.Sprintf("(%v)(%v)", name, fieldValue), nil - default: - if err := g.EnsureDeclared( - ` - type <.Name> - <$zapcore := import "go.uber.org/zap/zapcore"> - <$m := newVar "m"> - <$k := newVar "k"> - <$v := newVar "v"> - <$i := newVar "i"> - <$enc := newVar "enc"> - // MarshalLogArray implements zapcore.ArrayMarshaler, enabling - // fast logging of <.Name>. - func (<$m> <.Name>) MarshalLogArray(<$enc> <$zapcore>.ArrayEncoder) error { - - for <$k>, <$v> := range <$m> { - <- else -> - for _, <$i> := range <$m> { - <$k> := <$i>.Key - <$v> := <$i>.Value - <- end> - if err := <$enc>.AppendObject(); err != nil { - return err - } - } - return nil - } - `, struct { - Name string - Type *compile.MapSpec - }{ - Name: name, - Type: root, - }, - TemplateFunc("zapMapItemMarshaler", curryGenerator(m.zapMapItemMarshaler, g)), - ); err != nil { - return "", err - } - return fmt.Sprintf("(%v)(%v)", name, fieldValue), nil - } -} - -func (m *mapGenerator) zapMapItemMarshaler( - g Generator, - keySpec compile.TypeSpec, - keyVar string, - valueSpec compile.TypeSpec, - valueVar string, -) (string, error) { - name := fmt.Sprintf("_MapItem_%s_%s_Zapper", g.MangleType(keySpec), g.MangleType(valueSpec)) - if err := g.EnsureDeclared( - ` - type <.Name> struct { - Key - Value - } - <$zapcore := import "go.uber.org/zap/zapcore"> - <$v := newVar "v"> - <$key := printf "%s.%s" $v "Key"> - <$val := printf "%s.%s" $v "Value"> - <$enc := newVar "enc"> - // MarshalLogArray implements zapcore.ArrayMarshaler, enabling - // fast logging of <.Name>. - func (<$v> <.Name>) MarshalLogObject(<$enc> <$zapcore>.ObjectEncoder) error { - <- $encAddKey := printf "%s.Add%s(%q, %s)" $enc (zapEncoder .KeyType) "key" (zapMarshaler .KeyType $key)> - - if err := <$encAddKey>; err != nil { - return err - } - <- else -> - <$encAddKey> - <- end> - <- $encAddValue := printf "%s.Add%s(%q, %s)" $enc (zapEncoder .ValueType) "value" (zapMarshaler .ValueType $val)> - - if err := <$encAddValue>; err != nil { - return err - } - <- else -> - <$encAddValue> - <- end> - return nil - } - `, struct { - Name string - KeyType compile.TypeSpec - ValueType compile.TypeSpec - }{ - Name: name, - KeyType: keySpec, - ValueType: valueSpec, - }, - ); err != nil { - return "", err - } - return fmt.Sprintf("%v{Key: %v, Value: %v}", name, keyVar, valueVar), nil -} diff --git a/gen/set.go b/gen/set.go index d79fd511..fe246a73 100644 --- a/gen/set.go +++ b/gen/set.go @@ -20,11 +20,7 @@ package gen -import ( - "fmt" - - "go.uber.org/thriftrw/compile" -) +import "go.uber.org/thriftrw/compile" // setGenerator generates logic to convert lists of arbitrary Thrift types to // and from ValueLists. @@ -201,49 +197,3 @@ func (s *setGenerator) Equals(g Generator, spec *compile.SetSpec) (string, error return name, wrapGenerateError(spec.ThriftName(), err) } - -func (s *setGenerator) zapMarshaler( - g Generator, - spec compile.TypeSpec, - root *compile.SetSpec, - fieldValue string, -) (string, error) { - name := zapperName(g, spec) - if err := g.EnsureDeclared( - ` - type <.Name> - <$zapcore := import "go.uber.org/zap/zapcore"> - <$s := newVar "s"> - <$v := newVar "v"> - <$enc := newVar "enc"> - // MarshalLogArray implements zapcore.ArrayMarshaler, enabling - // fast logging of <.Name>. - func (<$s> <.Name>) MarshalLogArray(<$enc> <$zapcore>.ArrayEncoder) error { - - for <$v> := range <$s> { - <- else -> - for _, <$v> := range <$s> { - <- end> - <- $encAppend := printf "%s.Append%s(%s)" $enc (zapEncoder .Type.ValueSpec) (zapMarshaler .Type.ValueSpec $v)> - - if err := <$encAppend>; err != nil { - return err - } - <- else -> - <$encAppend> - <- end> - } - return nil - } - `, struct { - Name string - Type *compile.SetSpec - }{ - Name: name, - Type: root, - }, - ); err != nil { - return "", err - } - return fmt.Sprintf("(%v)(%v)", name, fieldValue), nil -} diff --git a/gen/type.go b/gen/type.go index 61ba8697..fa5fc2bd 100644 --- a/gen/type.go +++ b/gen/type.go @@ -193,10 +193,6 @@ func valueListName(g Generator, spec compile.TypeSpec) string { return fmt.Sprintf("_%s_ValueList", g.MangleType(spec)) } -func zapperName(g Generator, spec compile.TypeSpec) string { - return fmt.Sprintf("_%s_Zapper", g.MangleType(spec)) -} - // canBeConstant returns true if the given type can be a constant. func canBeConstant(t compile.TypeSpec) bool { // Only primitives can use const declarations. Everything else has to be a diff --git a/gen/typedef.go b/gen/typedef.go index 33580265..9da0f5e2 100644 --- a/gen/typedef.go +++ b/gen/typedef.go @@ -103,26 +103,6 @@ func typedef(g Generator, spec *compile.TypedefSpec) error { return <- end> } - - - <$zapcore := import "go.uber.org/zap/zapcore"> - <$enc := newVar "enc"> - func (<$v> <$typedefType>) MarshalLogObject(<$enc> <$zapcore>.ObjectEncoder) error { - - return (()(<$v>)).MarshalLogObject(<$enc>) - <- else -> - return ().MarshalLogObject(<$enc>) - <- end> - } - <- end> - - - <$zapcore := import "go.uber.org/zap/zapcore"> - <$enc := newVar "enc"> - func (<$v> <$typedefType>) MarshalLogArray(<$enc> <$zapcore>.ArrayEncoder) error { - return ().MarshalLogArray(<$enc>) - } - <- end> `, spec, ) diff --git a/gen/zap.go b/gen/zap.go deleted file mode 100644 index 68522118..00000000 --- a/gen/zap.go +++ /dev/null @@ -1,132 +0,0 @@ -// Copyright (c) 2018 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 gen - -import ( - "fmt" - - "go.uber.org/thriftrw/compile" -) - -type zapGenerator struct { - mapG mapGenerator - setG setGenerator - listG listGenerator -} - -func (z *zapGenerator) zapEncoder(g Generator, spec compile.TypeSpec) string { - root := compile.RootTypeSpec(spec) - - switch t := root.(type) { - // Primitives - case *compile.BoolSpec: - return "Bool" - case *compile.I8Spec: - return "Int8" - case *compile.I16Spec: - return "Int16" - case *compile.I32Spec: - return "Int32" - case *compile.I64Spec: - return "Int64" - case *compile.DoubleSpec: - return "Float64" - case *compile.StringSpec: - return "String" - case *compile.BinarySpec: - return "String" - - // Containers - case *compile.MapSpec: - switch t.KeySpec.(type) { - case *compile.StringSpec: - return "Object" - default: - return "Array" - } - case *compile.SetSpec, *compile.ListSpec: - return "Array" - - // User-defined - case *compile.EnumSpec, *compile.StructSpec: - return "Object" - } - panic(root) -} - -func (z *zapGenerator) zapMarshaler(g Generator, spec compile.TypeSpec, fieldValue string) (string, error) { - root := compile.RootTypeSpec(spec) - - if _, ok := spec.(*compile.TypedefSpec); ok { - // For typedefs, cast to the root type and rely on that functionality. - rootName, err := typeReference(g, root) - if err != nil { - return "", err - } - fieldValue = fmt.Sprintf("(%v)(%v)", rootName, fieldValue) - } - - if isPrimitiveType(spec) { - return fieldValue, nil - } - - switch t := root.(type) { - case *compile.BinarySpec: - // There is no AppendBinary for ArrayEncoder, so we opt for encoding it ourselves and - // appending it as a string. We also use AddString instead of AddBinary for ObjectEncoder - // for consistency. - base64 := g.Import("encoding/base64") - return fmt.Sprintf("%v.StdEncoding.EncodeToString(%v)", base64, fieldValue), nil - case *compile.MapSpec: - return z.mapG.zapMarshaler(g, spec, t, fieldValue) - case *compile.SetSpec: - return z.setG.zapMarshaler(g, spec, t, fieldValue) - case *compile.ListSpec: - return z.listG.zapMarshaler(g, spec, t, fieldValue) - case *compile.StructSpec: - return fieldValue, nil - } - panic(root) -} - -func (z *zapGenerator) zapMarshalerPtr(g Generator, spec compile.TypeSpec, fieldValue string) (string, error) { - if isPrimitiveType(spec) { - fieldValue = "*" + fieldValue - } - return z.zapMarshaler(g, spec, fieldValue) -} - -func (z *zapGenerator) zapCanError(spec compile.TypeSpec) bool { - root := compile.RootTypeSpec(spec) - - switch root.(type) { - // Primitives - case *compile.BoolSpec, *compile.I8Spec, *compile.I16Spec, *compile.I32Spec, - *compile.I64Spec, *compile.DoubleSpec, *compile.StringSpec, *compile.BinarySpec: - return false - - // Non-primitives - case *compile.MapSpec, *compile.SetSpec, *compile.ListSpec, *compile.EnumSpec, - *compile.StructSpec: - return true - } - panic(root) -} diff --git a/gen/zap_test.go b/gen/zap_test.go deleted file mode 100644 index 75c7d8ca..00000000 --- a/gen/zap_test.go +++ /dev/null @@ -1,532 +0,0 @@ -// Copyright (c) 2015 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 gen - -import ( - "encoding/base64" - "testing" - - "github.com/stretchr/testify/assert" - tc "go.uber.org/thriftrw/gen/internal/tests/containers" - te "go.uber.org/thriftrw/gen/internal/tests/enums" - ts "go.uber.org/thriftrw/gen/internal/tests/structs" - td "go.uber.org/thriftrw/gen/internal/tests/typedefs" - "go.uber.org/zap/zapcore" -) - -func TestCollectionsOfPrimitivesZapLogging(t *testing.T) { - // These types are created to ease building map[string]interface{} - type o = map[string]interface{} - type a = []interface{} - - b64 := func(byteString string) string { - return base64.StdEncoding.EncodeToString([]byte(byteString)) - } - - tests := []struct { - desc string - p tc.PrimitiveContainers - v interface{} - }{ - // Lists ///////////////////////////////////////////////////////////// - { - "empty list", - tc.PrimitiveContainers{ListOfInts: []int64{}}, - o{"listOfInts": a{}}, - }, - { - "list of ints", - tc.PrimitiveContainers{ListOfInts: []int64{1, 2, 3}}, - o{"listOfInts": a{int64(1), int64(2), int64(3)}}, - }, - { - "list of binary", - tc.PrimitiveContainers{ - ListOfBinary: [][]byte{ - []byte("foo"), {}, []byte("bar"), []byte("baz"), - }, - }, - // base64 - o{"listOfBinary": a{b64("foo"), b64(""), b64("bar"), b64("baz")}}, - }, - // Sets ////////////////////////////////////////////////////////////// - { - "empty set", - tc.PrimitiveContainers{SetOfStrings: map[string]struct{}{}}, - o{"setOfStrings": a{}}, - }, - { - "set of strings", - tc.PrimitiveContainers{SetOfStrings: map[string]struct{}{ - "foo": {}, - }}, - o{"setOfStrings": a{"foo"}}, - }, - { - "set of bytes", - tc.PrimitiveContainers{SetOfBytes: map[int8]struct{}{ - 125: {}, - }}, - o{"setOfBytes": a{int8(125)}}, - }, - // Maps ////////////////////////////////////////////////////////////// - { - "empty map", - tc.PrimitiveContainers{MapOfStringToBool: map[string]bool{}}, - o{"mapOfStringToBool": o{}}, - }, - { - "map of int to string", - tc.PrimitiveContainers{MapOfIntToString: map[int32]string{ - 1234: "bar", - }}, - o{"mapOfIntToString": a{ - o{"key": int32(1234), - "value": "bar"}, - }}, - }, - { - "map of string to bool", - tc.PrimitiveContainers{MapOfStringToBool: map[string]bool{ - "foo": false, - "bar": true, - "baz": true, - }}, - o{"mapOfStringToBool": o{"foo": false, "bar": true, "baz": true}}, - }, - } - - for _, tt := range tests { - mapEncoder := zapcore.NewMapObjectEncoder() - tt.p.MarshalLogObject(mapEncoder) - assert.Equal(t, tt.v, mapEncoder.Fields) - } -} - -func TestNondeterministicZapLogging(t *testing.T) { - mapEncoder := zapcore.NewMapObjectEncoder() - // case SetOfStrings - test1 := tc.PrimitiveContainers{ - SetOfStrings: map[string]struct{}{ - "foo": {}, - "bar": {}, - "baz": {}, - "hello": {}, - "world": {}, - }, - } - test1.MarshalLogObject(mapEncoder) - expected1 := []string{"foo", "bar", "baz", "hello", "world"} - assert.ElementsMatch(t, mapEncoder.Fields["setOfStrings"], expected1) - - // case SetOfBytes - test2 := tc.PrimitiveContainers{ - SetOfBytes: map[int8]struct{}{ - 125: {}, - 1: {}, - 5: {}, - 73: {}, - 42: {}, - }, - } - test2.MarshalLogObject(mapEncoder) - expected2 := []int8{1, 5, 42, 73, 125} - assert.ElementsMatch(t, mapEncoder.Fields["setOfBytes"], expected2) - - // case MapOfIntToString - test3 := tc.PrimitiveContainers{ - MapOfIntToString: map[int32]string{ - 125: "foo", - 1: "bar", - 5: "baz", - 73: "hello", - 42: "world", - }, - } - test3.MarshalLogObject(mapEncoder) - expected3 := []map[string]interface{}{ - {"key": int32(125), "value": "foo"}, - {"key": int32(1), "value": "bar"}, - {"key": int32(5), "value": "baz"}, - {"key": int32(73), "value": "hello"}, - {"key": int32(42), "value": "world"}, - } - assert.ElementsMatch(t, mapEncoder.Fields["mapOfIntToString"], expected3) -} - -func TestEnumContainersZapLogging(t *testing.T) { - // These types are created to ease building map[string]interface{} - type o = map[string]interface{} - type a = []interface{} - - tests := []struct { - r tc.EnumContainers - v interface{} - }{ - { - tc.EnumContainers{ - ListOfEnums: []te.EnumDefault{ - te.EnumDefaultBar, - }, - }, - o{"listOfEnums": a{ - o{"name": "Bar", "value": int32(1)}}, - }, - }, - { - tc.EnumContainers{ - SetOfEnums: map[te.EnumWithValues]struct{}{ - te.EnumWithValuesZ: {}, - }, - }, - o{"setOfEnums": a{ - o{"name": "Z", "value": int32(789)}}, - }, - }, - { - tc.EnumContainers{ - MapOfEnums: map[te.EnumWithDuplicateValues]int32{ - te.EnumWithDuplicateValuesP: 123, - }, - }, - o{"mapOfEnums": a{ - o{"key": o{"value": int32(0), "name": "P"}, "value": int32(123)}}}, - }, - { - // unknown enum name - tc.EnumContainers{ - MapOfEnums: map[te.EnumWithDuplicateValues]int32{ - te.EnumWithDuplicateValues(1523): 123, - }, - }, - o{"mapOfEnums": a{ - o{"key": o{"value": int32(1523)}, "value": int32(123)}}}, - }, - { - // this is the same as the one above except we're using "R" intsead - // of "P" (they both have the same value) - tc.EnumContainers{ - MapOfEnums: map[te.EnumWithDuplicateValues]int32{ - te.EnumWithDuplicateValuesR: 123, - }, - }, - o{"mapOfEnums": a{ - o{"key": o{"value": int32(0), "name": "P"}, "value": int32(123)}}}, - }, - } - - for _, tt := range tests { - mapEncoder := zapcore.NewMapObjectEncoder() - tt.r.MarshalLogObject(mapEncoder) - assert.Equal(t, tt.v, mapEncoder.Fields) - } -} - -func TestListOfStructsZapLogging(t *testing.T) { - // These types are created to ease building map[string]interface{} - type o = map[string]interface{} - type a = []interface{} - - tests := []struct { - r ts.Graph - v interface{} - }{ - { - ts.Graph{Edges: []*ts.Edge{}}, - o{"edges": a{}}, - }, - { - ts.Graph{Edges: []*ts.Edge{ - { - StartPoint: &ts.Point{X: 1.0, Y: 2.0}, - EndPoint: &ts.Point{X: 3.0, Y: 4.0}, - }, - { - StartPoint: &ts.Point{X: 5.0, Y: 6.0}, - EndPoint: &ts.Point{X: 7.0, Y: 8.0}, - }, - { - StartPoint: &ts.Point{X: 9.0, Y: 10.0}, - EndPoint: &ts.Point{X: 11.0, Y: 12.0}, - }, - }}, - o{"edges": a{ - o{"startPoint": o{"x": float64(1), "y": float64(2)}, - "endPoint": o{"x": float64(3), "y": float64(4)}}, - o{"startPoint": o{"x": float64(5), "y": float64(6)}, - "endPoint": o{"y": float64(8), "x": float64(7)}}, - o{"startPoint": o{"x": float64(9), "y": float64(10)}, - "endPoint": o{"x": float64(11), "y": float64(12)}}, - }, - }, - }, - } - - for _, tt := range tests { - mapEncoder := zapcore.NewMapObjectEncoder() - tt.r.MarshalLogObject(mapEncoder) - assert.Equal(t, tt.v, mapEncoder.Fields) - } -} - -func TestCrazyTownZapLogging(t *testing.T) { - // These types are created to ease building map[string]interface{} - type o = map[string]interface{} - type a = []interface{} - - tests := []struct { - desc string - r tc.ContainersOfContainers - v interface{} - }{ - { - "ListOfLists", - tc.ContainersOfContainers{ - ListOfLists: [][]int32{ - {1, 2, 3}, - {4, 5, 6}, - }, - }, - o{"listOfLists": a{ - a{int32(1), int32(2), int32(3)}, - a{int32(4), int32(5), int32(6)}}, - }, - }, - { - "ListOfSets", - tc.ContainersOfContainers{ - ListOfSets: []map[int32]struct{}{ - { - 2: struct{}{}, - }, - { - 5: struct{}{}, - }, - }, - }, - o{"listOfSets": a{ - a{int32(2)}, - a{int32(5)}}, - }, - }, - { - "ListOfMaps", - tc.ContainersOfContainers{ - ListOfMaps: []map[int32]int32{ - { - 2: 200, - }, - { - 5: 500, - }, - }, - }, - o{"listOfMaps": a{ - a{ - o{"key": int32(2), - "value": int32(200)}}, - a{ - o{"key": int32(5), - "value": int32(500)}}}, - }, - }, - { - "SetOfSets", - tc.ContainersOfContainers{ - SetOfSets: []map[string]struct{}{ - { - "2": struct{}{}, - }, - { - "5": struct{}{}, - }, - }, - }, - o{"setOfSets": a{ - a{"2"}, - a{"5"}}, - }, - }, - { - "SetOfLists", - tc.ContainersOfContainers{ - SetOfLists: [][]string{ - {"1", "2", "3"}, - {"4", "5", "6"}, - }, - }, - o{"setOfLists": a{ - a{"1", "2", "3"}, - a{"4", "5", "6"}}, - }, - }, - { - "SetOfMaps", - tc.ContainersOfContainers{ - SetOfMaps: []map[string]string{ - { - "2": "two", - }, - { - "6": "six", - }, - }, - }, - o{"setOfMaps": a{ - o{"2": "two"}, - o{"6": "six"}}, - }, - }, - { - "MapOfMapToInt", - tc.ContainersOfContainers{ - MapOfMapToInt: []struct { - Key map[string]int32 - Value int64 - }{ - { - Key: map[string]int32{"2": 2}, - Value: 123, - }, - { - Key: map[string]int32{"4": 4}, - Value: 135, - }, - }, - }, - o{"mapOfMapToInt": a{ - o{"key": o{"2": int32(2)}, - "value": int64(123)}, - o{"key": o{"4": int32(4)}, - "value": int64(135)}}, - }, - }, - { - "MapOfListToSet", - tc.ContainersOfContainers{ - MapOfListToSet: []struct { - Key []int32 - Value map[int64]struct{} - }{ - { - Key: []int32{1, 2, 3}, - Value: map[int64]struct{}{ - 1: {}, - }, - }, - }, - }, - o{"mapOfListToSet": a{ - o{"value": a{int64(1)}, - "key": a{int32(1), int32(2), int32(3)}}}, - }, - }, - { - "MapOfSetToListOfDouble", - tc.ContainersOfContainers{ - MapOfSetToListOfDouble: []struct { - Key map[int32]struct{} - Value []float64 - }{ - { - Key: map[int32]struct{}{ - 2: {}, - }, - Value: []float64{1.1, 2.2, 3.3}, - }, - { - Key: map[int32]struct{}{ - 4: {}, - }, - Value: []float64{2.2, 3.3}, - }, - }, - }, - o{"mapOfSetToListOfDouble": a{ - o{"key": a{int32(2)}, - "value": a{float64(1.1), float64(2.2), float64(3.3)}}, - o{"key": a{int32(4)}, - "value": a{float64(2.2), float64(3.3)}}}, - }, - }, - } - - for _, tt := range tests { - mapEncoder := zapcore.NewMapObjectEncoder() - tt.r.MarshalLogObject(mapEncoder) - assert.Equal(t, tt.v, mapEncoder.Fields) - } -} - -func TestTypedefsZapLogging(t *testing.T) { - // These types are created to ease building map[string]interface{} - type o = map[string]interface{} - type a = []interface{} - - // test alias of primitive - mapEncoder := zapcore.NewMapObjectEncoder() - testState := td.State("hello") - test1 := td.DefaultPrimitiveTypedef{State: &testState} - test1.MarshalLogObject(mapEncoder) - expected1 := o{"state": "hello"} - assert.Equal(t, expected1, mapEncoder.Fields) - - // test alias of struct - mapEncoder = zapcore.NewMapObjectEncoder() - test2 := td.UUID{High: 123, Low: 456} - test2.MarshalLogObject(mapEncoder) - expected2 := o{"high": int64(123), "low": int64(456)} - assert.Equal(t, expected2, mapEncoder.Fields) - - // test alias of list of structs - mapEncoder = zapcore.NewMapObjectEncoder() - testUUID := td.UUID(td.I128{High: 123, Low: 456}) - testTimestamp := td.Timestamp(123) - test3 := td.EventGroup([]*td.Event{ - &td.Event{ - UUID: &testUUID, - Time: &testTimestamp, - }, - }) - mapEncoder.AddArray("addTypedefArrayTest", test3) - expected3 := o{"addTypedefArrayTest": a{o{"uuid": o{"high": int64(123), "low": int64(456)}, "time": int64(123)}}} - assert.Equal(t, expected3, mapEncoder.Fields) - - // test alias of set - b64 := func(byteString string) string { - return base64.StdEncoding.EncodeToString([]byte(byteString)) - } - mapEncoder = zapcore.NewMapObjectEncoder() - test4 := td.BinarySet([][]byte{ - []byte("foo"), {}, []byte("bar"), []byte("baz"), - }) - mapEncoder.AddArray("addTypedefSetTest", test4) - // base64 - expected4 := o{"addTypedefSetTest": a{b64("foo"), b64(""), b64("bar"), b64("baz")}} - assert.Equal(t, expected4, mapEncoder.Fields) - - // test alias of enums - mapEncoder = zapcore.NewMapObjectEncoder() - test5 := td.MyEnum(te.EnumWithValuesX) - test5.MarshalLogObject(mapEncoder) - expected5 := o{"value": int32(123), "name": "X"} - assert.Equal(t, expected5, mapEncoder.Fields) -} diff --git a/glide.lock b/glide.lock index 3763a1b4..8697b2b6 100644 --- a/glide.lock +++ b/glide.lock @@ -1,51 +1,39 @@ -hash: de4f56d34612433b7a80991786d4a9bf401fbd8d74bfd4b53e8a277e7f93bd6e -updated: 2018-08-06T11:16:47.428919733-07:00 +hash: 26c2c55ca402d6605deed8219389876b6207f46109135620b0f6ec7f84ca1a84 +updated: 2018-04-24T13:31:10.646395712-07:00 imports: - name: github.com/anmitsu/go-shlex version: 648efa622239a2f6ff949fed78ee37b48d499ba4 - name: github.com/fatih/structtag version: da3d9ab5b78fdc25d3a7614853b085200bd10da9 - name: github.com/golang/mock - version: c34cdb4725f4c3844d095133c6e40e448b86589b + version: 13f360950a79f5864a972c786a10a50e44b69541 subpackages: - gomock - name: github.com/jessevdk/go-flags - version: c6ca198ec95c841fdb89fc0de7496fed11ab854e + version: 6cf8f02b4ae8ba723ddc64dcfd403e530c06d927 - name: github.com/kr/pretty - version: 73f6ac0b30a98e433b289500d779f50c1a6f0712 + version: cfb55aafdaf3ec08f0db22699ab822c50091b1c4 - name: github.com/kr/text - version: e2ffdb16a802fe2bb95e2e35ff34f0e53aeef34f + version: 7cafcd837844e784b526369c9bce262804aebc60 - name: go.uber.org/atomic - version: 1ea20fb1cbb1cc08cbd0d913a96dead89aa18289 + version: 8474b86a5a6f79c443ce4b2992817ff32cf208b8 - name: go.uber.org/multierr version: 3c4937480c32f4c13a875a1829af76c98ca3d40a -- name: go.uber.org/zap - version: ff33455a0e382e8a81d14dd7c922020b6b5e7982 - subpackages: - - buffer - - internal/bufferpool - - internal/color - - internal/exit - - zapcore -- name: golang.org/x/net - version: f4c29de78a2a91c00474a2e689954305c350adf9 - subpackages: - - context - name: golang.org/x/tools - version: 3c07937fe18c27668fd78bbaed3d6b8b39e202ea + version: 4e70a1b26a7875f00ca1916637a876b5ffaeec59 subpackages: - go/ast/astutil testImports: - name: github.com/davecgh/go-spew - version: 8991bc29aa16c548c550c7ff78260e27b9ab7c73 + version: 6d212800a42e8ab5c146b8ace3490ee17e5225f9 subpackages: - spew - name: github.com/pmezard/go-difflib - version: 792786c7400a136282c1664665ae0a8db921c6c2 + version: d8ed2627bdf02c080bf22230dbb337003b7aba2d subpackages: - difflib - name: github.com/stretchr/testify - version: f35b8ab0b5a2cef36673838d662e249dd9c94686 + version: 12b6f73e6084dad08a7c6e575284b177ecafbc71 subpackages: - assert - require diff --git a/glide.yaml b/glide.yaml index 40ba5547..978b5dcc 100644 --- a/glide.yaml +++ b/glide.yaml @@ -12,8 +12,6 @@ import: version: ^1 - package: github.com/fatih/structtag version: ^0.1.0 -- package: go.uber.org/zap - version: ^1 testImport: - package: github.com/golang/mock subpackages: diff --git a/internal/envelope/exception/types.go b/internal/envelope/exception/types.go index ad79ac62..175d9322 100644 --- a/internal/envelope/exception/types.go +++ b/internal/envelope/exception/types.go @@ -28,7 +28,6 @@ import ( "encoding/json" "fmt" "go.uber.org/thriftrw/wire" - "go.uber.org/zap/zapcore" "math" "strconv" "strings" @@ -146,37 +145,6 @@ func (v ExceptionType) MarshalText() ([]byte, error) { return []byte(strconv.FormatInt(int64(v), 10)), nil } -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of ExceptionType. -func (v ExceptionType) MarshalLogObject(enc zapcore.ObjectEncoder) error { - enc.AddInt32("value", int32(v)) - switch int32(v) { - case 0: - enc.AddString("name", "UNKNOWN") - case 1: - enc.AddString("name", "UNKNOWN_METHOD") - case 2: - enc.AddString("name", "INVALID_MESSAGE_TYPE") - case 3: - enc.AddString("name", "WRONG_METHOD_NAME") - case 4: - enc.AddString("name", "BAD_SEQUENCE_ID") - case 5: - enc.AddString("name", "MISSING_RESULT") - case 6: - enc.AddString("name", "INTERNAL_ERROR") - case 7: - enc.AddString("name", "PROTOCOL_ERROR") - case 8: - enc.AddString("name", "INVALID_TRANSFORM") - case 9: - enc.AddString("name", "INVALID_PROTOCOL") - case 10: - enc.AddString("name", "UNSUPPORTED_CLIENT_TYPE") - } - return nil -} - // Ptr returns a pointer to this enum value. func (v ExceptionType) Ptr() *ExceptionType { return &v @@ -473,21 +441,6 @@ func (v *TApplicationException) Equals(rhs *TApplicationException) bool { return true } -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of TApplicationException. -func (v *TApplicationException) MarshalLogObject(enc zapcore.ObjectEncoder) error { - if v.Message != nil { - enc.AddString("message", *v.Message) - } - if v.Type != nil { - if err := enc.AddObject("type", *v.Type); err != nil { - return err - } - } - - return nil -} - // GetMessage returns the value of Message if it is set or its // zero value if it is unset. func (v *TApplicationException) GetMessage() (o string) { diff --git a/plugin/api/plugin_goodbye.go b/plugin/api/plugin_goodbye.go index b7d00418..29760620 100644 --- a/plugin/api/plugin_goodbye.go +++ b/plugin/api/plugin_goodbye.go @@ -26,7 +26,6 @@ package api import ( "fmt" "go.uber.org/thriftrw/wire" - "go.uber.org/zap/zapcore" "strings" ) @@ -109,13 +108,6 @@ func (v *Plugin_Goodbye_Args) Equals(rhs *Plugin_Goodbye_Args) bool { return true } -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of Plugin_Goodbye_Args. -func (v *Plugin_Goodbye_Args) MarshalLogObject(enc zapcore.ObjectEncoder) error { - - return nil -} - // MethodName returns the name of the Thrift function as specified in // the IDL, for which this struct represent the arguments. // @@ -279,13 +271,6 @@ func (v *Plugin_Goodbye_Result) Equals(rhs *Plugin_Goodbye_Result) bool { return true } -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of Plugin_Goodbye_Result. -func (v *Plugin_Goodbye_Result) MarshalLogObject(enc zapcore.ObjectEncoder) error { - - return nil -} - // MethodName returns the name of the Thrift function as specified in // the IDL, for which this struct represent the result. // diff --git a/plugin/api/plugin_handshake.go b/plugin/api/plugin_handshake.go index 36d971c3..c5cc1d51 100644 --- a/plugin/api/plugin_handshake.go +++ b/plugin/api/plugin_handshake.go @@ -27,7 +27,6 @@ import ( "errors" "fmt" "go.uber.org/thriftrw/wire" - "go.uber.org/zap/zapcore" "strings" ) @@ -144,18 +143,6 @@ func (v *Plugin_Handshake_Args) Equals(rhs *Plugin_Handshake_Args) bool { return true } -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of Plugin_Handshake_Args. -func (v *Plugin_Handshake_Args) MarshalLogObject(enc zapcore.ObjectEncoder) error { - if v.Request != nil { - if err := enc.AddObject("request", v.Request); err != nil { - return err - } - } - - return nil -} - // GetRequest returns the value of Request if it is set or its // zero value if it is unset. func (v *Plugin_Handshake_Args) GetRequest() (o *HandshakeRequest) { @@ -390,18 +377,6 @@ func (v *Plugin_Handshake_Result) Equals(rhs *Plugin_Handshake_Result) bool { return true } -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of Plugin_Handshake_Result. -func (v *Plugin_Handshake_Result) MarshalLogObject(enc zapcore.ObjectEncoder) error { - if v.Success != nil { - if err := enc.AddObject("success", v.Success); err != nil { - return err - } - } - - return nil -} - // GetSuccess returns the value of Success if it is set or its // zero value if it is unset. func (v *Plugin_Handshake_Result) GetSuccess() (o *HandshakeResponse) { diff --git a/plugin/api/servicegenerator_generate.go b/plugin/api/servicegenerator_generate.go index 4bdeb5cf..c3d2ffc3 100644 --- a/plugin/api/servicegenerator_generate.go +++ b/plugin/api/servicegenerator_generate.go @@ -27,7 +27,6 @@ import ( "errors" "fmt" "go.uber.org/thriftrw/wire" - "go.uber.org/zap/zapcore" "strings" ) @@ -144,18 +143,6 @@ func (v *ServiceGenerator_Generate_Args) Equals(rhs *ServiceGenerator_Generate_A return true } -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of ServiceGenerator_Generate_Args. -func (v *ServiceGenerator_Generate_Args) MarshalLogObject(enc zapcore.ObjectEncoder) error { - if v.Request != nil { - if err := enc.AddObject("request", v.Request); err != nil { - return err - } - } - - return nil -} - // GetRequest returns the value of Request if it is set or its // zero value if it is unset. func (v *ServiceGenerator_Generate_Args) GetRequest() (o *GenerateServiceRequest) { @@ -390,18 +377,6 @@ func (v *ServiceGenerator_Generate_Result) Equals(rhs *ServiceGenerator_Generate return true } -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of ServiceGenerator_Generate_Result. -func (v *ServiceGenerator_Generate_Result) MarshalLogObject(enc zapcore.ObjectEncoder) error { - if v.Success != nil { - if err := enc.AddObject("success", v.Success); err != nil { - return err - } - } - - return nil -} - // GetSuccess returns the value of Success if it is set or its // zero value if it is unset. func (v *ServiceGenerator_Generate_Result) GetSuccess() (o *GenerateServiceResponse) { diff --git a/plugin/api/types.go b/plugin/api/types.go index 750ce6fa..8f71a925 100644 --- a/plugin/api/types.go +++ b/plugin/api/types.go @@ -25,12 +25,10 @@ package api import ( "bytes" - "encoding/base64" "encoding/json" "errors" "fmt" "go.uber.org/thriftrw/wire" - "go.uber.org/zap/zapcore" "math" "strconv" "strings" @@ -189,18 +187,6 @@ func (v *Argument) Equals(rhs *Argument) bool { return true } -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of Argument. -func (v *Argument) MarshalLogObject(enc zapcore.ObjectEncoder) error { - enc.AddString("name", v.Name) - - if err := enc.AddObject("type", v.Type); err != nil { - return err - } - - return nil -} - // GetName returns the value of Name if it is set or its // zero value if it is unset. func (v *Argument) GetName() (o string) { return v.Name } @@ -257,17 +243,6 @@ func (v Feature) MarshalText() ([]byte, error) { return []byte(strconv.FormatInt(int64(v), 10)), nil } -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of Feature. -func (v Feature) MarshalLogObject(enc zapcore.ObjectEncoder) error { - enc.AddInt32("value", int32(v)) - switch int32(v) { - case 1: - enc.AddString("name", "SERVICE_GENERATOR") - } - return nil -} - // Ptr returns a pointer to this enum value. func (v Feature) Ptr() *Feature { return &v @@ -807,61 +782,6 @@ func (v *Function) Equals(rhs *Function) bool { return true } -type _List_Argument_Zapper []*Argument - -// MarshalLogArray implements zapcore.ArrayMarshaler, enabling -// fast logging of _List_Argument_Zapper. -func (l _List_Argument_Zapper) MarshalLogArray(enc zapcore.ArrayEncoder) error { - for _, v := range l { - if err := enc.AppendObject(v); err != nil { - return err - } - } - return nil -} - -type _Map_String_String_Zapper map[string]string - -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of _Map_String_String_Zapper. -func (m _Map_String_String_Zapper) MarshalLogObject(enc zapcore.ObjectEncoder) error { - for k, v := range m { - enc.AddString((string)(k), v) - } - return nil -} - -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of Function. -func (v *Function) MarshalLogObject(enc zapcore.ObjectEncoder) error { - enc.AddString("name", v.Name) - enc.AddString("thriftName", v.ThriftName) - - if err := enc.AddArray("arguments", (_List_Argument_Zapper)(v.Arguments)); err != nil { - return err - } - if v.ReturnType != nil { - if err := enc.AddObject("returnType", v.ReturnType); err != nil { - return err - } - } - if v.Exceptions != nil { - if err := enc.AddArray("exceptions", (_List_Argument_Zapper)(v.Exceptions)); err != nil { - return err - } - } - if v.OneWay != nil { - enc.AddBool("oneWay", *v.OneWay) - } - if v.Annotations != nil { - if err := enc.AddObject("annotations", (_Map_String_String_Zapper)(v.Annotations)); err != nil { - return err - } - } - - return nil -} - // GetName returns the value of Name if it is set or its // zero value if it is unset. func (v *Function) GetName() (o string) { return v.Name } @@ -1344,92 +1264,6 @@ func (v *GenerateServiceRequest) Equals(rhs *GenerateServiceRequest) bool { return true } -type _List_ServiceID_Zapper []ServiceID - -// MarshalLogArray implements zapcore.ArrayMarshaler, enabling -// fast logging of _List_ServiceID_Zapper. -func (l _List_ServiceID_Zapper) MarshalLogArray(enc zapcore.ArrayEncoder) error { - for _, v := range l { - enc.AppendInt32((int32)(v)) - } - return nil -} - -type _MapItem_ServiceID_Service_Zapper struct { - Key ServiceID - Value *Service -} - -// MarshalLogArray implements zapcore.ArrayMarshaler, enabling -// fast logging of _MapItem_ServiceID_Service_Zapper. -func (v _MapItem_ServiceID_Service_Zapper) MarshalLogObject(enc zapcore.ObjectEncoder) error { - enc.AddInt32("key", (int32)(v.Key)) - if err := enc.AddObject("value", v.Value); err != nil { - return err - } - return nil -} - -type _Map_ServiceID_Service_Zapper map[ServiceID]*Service - -// MarshalLogArray implements zapcore.ArrayMarshaler, enabling -// fast logging of _Map_ServiceID_Service_Zapper. -func (m _Map_ServiceID_Service_Zapper) MarshalLogArray(enc zapcore.ArrayEncoder) error { - for k, v := range m { - if err := enc.AppendObject(_MapItem_ServiceID_Service_Zapper{Key: k, Value: v}); err != nil { - return err - } - } - return nil -} - -type _MapItem_ModuleID_Module_Zapper struct { - Key ModuleID - Value *Module -} - -// MarshalLogArray implements zapcore.ArrayMarshaler, enabling -// fast logging of _MapItem_ModuleID_Module_Zapper. -func (v _MapItem_ModuleID_Module_Zapper) MarshalLogObject(enc zapcore.ObjectEncoder) error { - enc.AddInt32("key", (int32)(v.Key)) - if err := enc.AddObject("value", v.Value); err != nil { - return err - } - return nil -} - -type _Map_ModuleID_Module_Zapper map[ModuleID]*Module - -// MarshalLogArray implements zapcore.ArrayMarshaler, enabling -// fast logging of _Map_ModuleID_Module_Zapper. -func (m _Map_ModuleID_Module_Zapper) MarshalLogArray(enc zapcore.ArrayEncoder) error { - for k, v := range m { - if err := enc.AppendObject(_MapItem_ModuleID_Module_Zapper{Key: k, Value: v}); err != nil { - return err - } - } - return nil -} - -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of GenerateServiceRequest. -func (v *GenerateServiceRequest) MarshalLogObject(enc zapcore.ObjectEncoder) error { - - if err := enc.AddArray("rootServices", (_List_ServiceID_Zapper)(v.RootServices)); err != nil { - return err - } - - if err := enc.AddArray("services", (_Map_ServiceID_Service_Zapper)(v.Services)); err != nil { - return err - } - - if err := enc.AddArray("modules", (_Map_ModuleID_Module_Zapper)(v.Modules)); err != nil { - return err - } - - return nil -} - // GetRootServices returns the value of RootServices if it is set or its // zero value if it is unset. func (v *GenerateServiceRequest) GetRootServices() (o []ServiceID) { return v.RootServices } @@ -1637,29 +1471,6 @@ func (v *GenerateServiceResponse) Equals(rhs *GenerateServiceResponse) bool { return true } -type _Map_String_Binary_Zapper map[string][]byte - -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of _Map_String_Binary_Zapper. -func (m _Map_String_Binary_Zapper) MarshalLogObject(enc zapcore.ObjectEncoder) error { - for k, v := range m { - enc.AddString((string)(k), base64.StdEncoding.EncodeToString(v)) - } - return nil -} - -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of GenerateServiceResponse. -func (v *GenerateServiceResponse) MarshalLogObject(enc zapcore.ObjectEncoder) error { - if v.Files != nil { - if err := enc.AddObject("files", (_Map_String_Binary_Zapper)(v.Files)); err != nil { - return err - } - } - - return nil -} - // GetFiles returns the value of Files if it is set or its // zero value if it is unset. func (v *GenerateServiceResponse) GetFiles() (o map[string][]byte) { @@ -1748,13 +1559,6 @@ func (v *HandshakeRequest) Equals(rhs *HandshakeRequest) bool { return true } -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of HandshakeRequest. -func (v *HandshakeRequest) MarshalLogObject(enc zapcore.ObjectEncoder) error { - - return nil -} - // HandshakeResponse is the response from the plugin for a HandshakeRequest. type HandshakeResponse struct { // Name of the plugin. This MUST match the name of the plugin specified @@ -2027,35 +1831,6 @@ func (v *HandshakeResponse) Equals(rhs *HandshakeResponse) bool { return true } -type _List_Feature_Zapper []Feature - -// MarshalLogArray implements zapcore.ArrayMarshaler, enabling -// fast logging of _List_Feature_Zapper. -func (l _List_Feature_Zapper) MarshalLogArray(enc zapcore.ArrayEncoder) error { - for _, v := range l { - if err := enc.AppendObject(v); err != nil { - return err - } - } - return nil -} - -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of HandshakeResponse. -func (v *HandshakeResponse) MarshalLogObject(enc zapcore.ObjectEncoder) error { - enc.AddString("name", v.Name) - enc.AddInt32("apiVersion", v.APIVersion) - - if err := enc.AddArray("features", (_List_Feature_Zapper)(v.Features)); err != nil { - return err - } - if v.LibraryVersion != nil { - enc.AddString("libraryVersion", *v.LibraryVersion) - } - - return nil -} - // GetName returns the value of Name if it is set or its // zero value if it is unset. func (v *HandshakeResponse) GetName() (o string) { return v.Name } @@ -2219,15 +1994,6 @@ func (v *Module) Equals(rhs *Module) bool { return true } -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of Module. -func (v *Module) MarshalLogObject(enc zapcore.ObjectEncoder) error { - enc.AddString("importPath", v.ImportPath) - enc.AddString("directory", v.Directory) - - return nil -} - // GetImportPath returns the value of ImportPath if it is set or its // zero value if it is unset. func (v *Module) GetImportPath() (o string) { return v.ImportPath } @@ -2602,41 +2368,6 @@ func (v *Service) Equals(rhs *Service) bool { return true } -type _List_Function_Zapper []*Function - -// MarshalLogArray implements zapcore.ArrayMarshaler, enabling -// fast logging of _List_Function_Zapper. -func (l _List_Function_Zapper) MarshalLogArray(enc zapcore.ArrayEncoder) error { - for _, v := range l { - if err := enc.AppendObject(v); err != nil { - return err - } - } - return nil -} - -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of Service. -func (v *Service) MarshalLogObject(enc zapcore.ObjectEncoder) error { - enc.AddString("name", v.Name) - enc.AddString("thriftName", v.ThriftName) - if v.ParentID != nil { - enc.AddInt32("parentID", (int32)(*v.ParentID)) - } - - if err := enc.AddArray("functions", (_List_Function_Zapper)(v.Functions)); err != nil { - return err - } - enc.AddInt32("moduleID", (int32)(v.ModuleID)) - if v.Annotations != nil { - if err := enc.AddObject("annotations", (_Map_String_String_Zapper)(v.Annotations)); err != nil { - return err - } - } - - return nil -} - // GetName returns the value of Name if it is set or its // zero value if it is unset. func (v *Service) GetName() (o string) { return v.Name } @@ -2805,33 +2536,6 @@ func (v SimpleType) MarshalText() ([]byte, error) { return []byte(strconv.FormatInt(int64(v), 10)), nil } -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of SimpleType. -func (v SimpleType) MarshalLogObject(enc zapcore.ObjectEncoder) error { - enc.AddInt32("value", int32(v)) - switch int32(v) { - case 1: - enc.AddString("name", "BOOL") - case 2: - enc.AddString("name", "BYTE") - case 3: - enc.AddString("name", "INT8") - case 4: - enc.AddString("name", "INT16") - case 5: - enc.AddString("name", "INT32") - case 6: - enc.AddString("name", "INT64") - case 7: - enc.AddString("name", "FLOAT64") - case 8: - enc.AddString("name", "STRING") - case 9: - enc.AddString("name", "STRUCT_EMPTY") - } - return nil -} - // Ptr returns a pointer to this enum value. func (v SimpleType) Ptr() *SimpleType { return &v @@ -3255,43 +2959,6 @@ func (v *Type) Equals(rhs *Type) bool { return true } -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of Type. -func (v *Type) MarshalLogObject(enc zapcore.ObjectEncoder) error { - if v.SimpleType != nil { - if err := enc.AddObject("simpleType", *v.SimpleType); err != nil { - return err - } - } - if v.SliceType != nil { - if err := enc.AddObject("sliceType", v.SliceType); err != nil { - return err - } - } - if v.KeyValueSliceType != nil { - if err := enc.AddObject("keyValueSliceType", v.KeyValueSliceType); err != nil { - return err - } - } - if v.MapType != nil { - if err := enc.AddObject("mapType", v.MapType); err != nil { - return err - } - } - if v.ReferenceType != nil { - if err := enc.AddObject("referenceType", v.ReferenceType); err != nil { - return err - } - } - if v.PointerType != nil { - if err := enc.AddObject("pointerType", v.PointerType); err != nil { - return err - } - } - - return nil -} - // GetSimpleType returns the value of SimpleType if it is set or its // zero value if it is unset. func (v *Type) GetSimpleType() (o SimpleType) { @@ -3490,21 +3157,6 @@ func (v *TypePair) Equals(rhs *TypePair) bool { return true } -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of TypePair. -func (v *TypePair) MarshalLogObject(enc zapcore.ObjectEncoder) error { - - if err := enc.AddObject("left", v.Left); err != nil { - return err - } - - if err := enc.AddObject("right", v.Right); err != nil { - return err - } - - return nil -} - // GetLeft returns the value of Left if it is set or its // zero value if it is unset. func (v *TypePair) GetLeft() (o *Type) { return v.Left } @@ -3689,20 +3341,6 @@ func (v *TypeReference) Equals(rhs *TypeReference) bool { return true } -// MarshalLogObject implements zapcore.ObjectMarshaler, enabling -// fast logging of TypeReference. -func (v *TypeReference) MarshalLogObject(enc zapcore.ObjectEncoder) error { - enc.AddString("name", v.Name) - enc.AddString("importPath", v.ImportPath) - if v.Annotations != nil { - if err := enc.AddObject("annotations", (_Map_String_String_Zapper)(v.Annotations)); err != nil { - return err - } - } - - return nil -} - // GetName returns the value of Name if it is set or its // zero value if it is unset. func (v *TypeReference) GetName() (o string) { return v.Name }