├── LICENSE.txt ├── Makefile ├── README.md ├── examples ├── example.proto ├── zap-marshaler-secure │ ├── example.pb.go │ ├── example.proto │ ├── example.zap.go │ └── example_test.go └── zap-marshaler │ ├── example.pb.go │ ├── example.proto │ ├── example.zap.go │ └── example_test.go ├── plugin └── plugin.go ├── protoc-gen-zap-marshaler-secure └── main.go ├── protoc-gen-zap-marshaler └── main.go ├── zap_marshaler.pb.go └── zap_marshaler.proto /LICENSE.txt: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Masahiro Sano 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | REPOSITORY=github.com/kazegusuri/go-proto-zap-marshaler 2 | 3 | regenerate: 4 | $(MAKE) regenerate/proto 5 | $(MAKE) regenerate/examples 6 | 7 | regenerate/proto: 8 | rm -rf gen && mkdir -p gen 9 | protoc -I. -I${GOPATH}/src --gogo_out=Mgoogle/protobuf/descriptor.proto=github.com/gogo/protobuf/protoc-gen-gogo/descriptor:gen zap_marshaler.proto 10 | mv gen/$(REPOSITORY)/zap_marshaler.pb.go ./ 11 | 12 | regenerate/examples: 13 | cp examples/*.proto examples/zap-marshaler/ 14 | protoc -I. --go_out=. examples/zap-marshaler/*.proto 15 | protoc -I. --zap-marshaler_out=. examples/zap-marshaler/*.proto 16 | 17 | cp examples/*.proto examples/zap-marshaler-secure/ 18 | protoc -I. --go_out=. examples/zap-marshaler-secure/*.proto 19 | protoc -I. --zap-marshaler-secure_out=. examples/zap-marshaler-secure/*.proto 20 | 21 | install: 22 | go install $(REPOSITORY)/protoc-gen-zap-marshaler 23 | go install $(REPOSITORY)/protoc-gen-zap-marshaler-secure 24 | 25 | test: 26 | go test -v $(REPOSITORY)/examples/... 27 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # go-proto-zap-marshaler 2 | 3 | A protoc plugin whitch generates `MarshalLogObject()` functions for each generated go structs to implement `zapcore.ObjectMarshaler` interface for [uber-go/zap](https://github.com/uber-go/zap). So you can use `zap.Object("proto", someProtoMessage)` to log contents of the proto message. 4 | 5 | ## Install 6 | 7 | There are 2 protoc plugins to generate marshaler functions for zap: 8 | 9 | * `protoc-gen-zap-marshaler` 10 | * which genearetes marshaler functions for all messages. 11 | * `protoc-gen-zap-marshaler-secure` 12 | * which genearetes marshaler functions for all messages, but only logs fields enabled by proto option. 13 | 14 | You can install those plugins by the following command: 15 | 16 | ```bash 17 | $ go get github.com/kazegusuri/go-proto-zap-marshaler/protoc-gen-zap-marshaler 18 | $ go get github.com/kazegusuri/go-proto-zap-marshaler/protoc-gen-zap-marshaler-secure 19 | ``` 20 | 21 | ## Usage 22 | 23 | ### protoc-gen-zap-marshaler 24 | 25 | To generate marshaler functions from proto, use `--zap-marshaler_out` with `protoc` command. That runs `protoc-gen-zap-marshaler` internally and then generates `*.zap.go` files. 26 | 27 | ``` 28 | $ protoc --zap-marshaler_out=. path/to/example.proto 29 | ``` 30 | 31 | ### protoc-gen-zap-marshaler-secure 32 | 33 | This plugin generates marshaler functions as well as `protoc-gen-zap-marshaler`, but the funtions does not log anything as default. The marshaler only marshal fields enabled by [zap_marshaler](https://github.com/kazegusuri/go-proto-zap-marshaler/blob/master/zap_marshaler.proto) option. 34 | 35 | 36 | To enable field option for message fields, you need to define proto like this: 37 | 38 | ```proto 39 | message SimpleMessage { 40 | string string_value = 1 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 41 | bool bool_value = 2 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 42 | } 43 | ``` 44 | 45 | To generate marshaler functions from proto, use `--zap-marshaler-secure_out` with `protoc` command. That runs `protoc-gen-zap-marshaler-secure` internally and then generates `*.zap.go` files. 46 | 47 | ``` 48 | $ protoc --zap-marshaler-secure_out=. path/to/example.proto 49 | ``` 50 | 51 | #### Field option 52 | 53 | ```proto 54 | message ZapMarshalerRule { 55 | bool enabled = 1; 56 | } 57 | ``` 58 | 59 | * `enabled` 60 | * The marshaler only logs a field whose value is true 61 | 62 | #### Example 63 | 64 | For this proto without field option, the secure plugin generates a go function: 65 | 66 | ```proto 67 | syntax = "proto3"; 68 | package example; 69 | 70 | message SimpleMessage { 71 | string string_value = 1; 72 | bool bool_value = 2; 73 | } 74 | ``` 75 | 76 | ```go 77 | func (m *SimpleMessage) MarshalLogObject(enc go_uber_org_zap_zapcore.ObjectEncoder) error { 78 | var keyName string 79 | _ = keyName 80 | 81 | return nil 82 | } 83 | ``` 84 | 85 | The generated function does nothing. 86 | 87 | By changing the proto with field option like this, the secure plugin generates a go function: 88 | 89 | 90 | ```proto 91 | syntax = "proto3"; 92 | package example; 93 | 94 | import "kazegusuri/go-prot-zap-marshaler/zap_marshaler.proto"; 95 | 96 | message SimpleMessage { 97 | string string_value = 1 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 98 | bool bool_value = 2 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 99 | } 100 | ``` 101 | 102 | ```go 103 | func (m *SimpleMessage) MarshalLogObject(enc go_uber_org_zap_zapcore.ObjectEncoder) error { 104 | var keyName string 105 | _ = keyName 106 | 107 | keyName = "string_value" // field string_value = 1 108 | enc.AddString(keyName, m.StringValue) 109 | 110 | keyName = "bool_value" // field bool_value = 2 111 | enc.AddBool(keyName, m.BoolValue) 112 | 113 | return nil 114 | } 115 | ``` 116 | -------------------------------------------------------------------------------- /examples/example.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package kazegusuri.zapmarshaler.example; 4 | option go_package = "examples"; 5 | 6 | import "zap_marshaler.proto"; 7 | import "google/protobuf/duration.proto"; 8 | import "google/protobuf/timestamp.proto"; 9 | 10 | message SimpleMessage { 11 | string string_value = 1 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 12 | bool bool_value = 2 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 13 | } 14 | 15 | message NotLoggingSimpleMessage { 16 | string string_value = 1; 17 | bool bool_value = 2; 18 | } 19 | 20 | message NumberMessage { 21 | float float_value = 1 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 22 | double double_value = 2 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 23 | 24 | int32 int32_value = 3 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 25 | int64 int64_value = 4 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 26 | uint32 uint32_value = 5 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 27 | uint64 uint64_value = 6 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 28 | sint32 sint32_value = 7 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 29 | sint64 sint64_value = 8 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 30 | 31 | fixed32 fixed32_value = 9 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 32 | fixed64 fixed64_value = 10 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 33 | sfixed32 sfixed32_value = 11 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 34 | sfixed64 sfixed64_value = 12 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 35 | } 36 | 37 | message NotLoggingNumberMessage { 38 | float float_value = 1; 39 | double double_value = 2; 40 | 41 | int32 int32_value = 3; 42 | int64 int64_value = 4; 43 | uint32 uint32_value = 5; 44 | uint64 uint64_value = 6; 45 | sint32 sint32_value = 7; 46 | sint64 sint64_value = 8; 47 | 48 | fixed32 fixed32_value = 9; 49 | fixed64 fixed64_value = 10; 50 | sfixed32 sfixed32_value = 11; 51 | sfixed64 sfixed64_value = 12; 52 | } 53 | 54 | message RepeatedNumberMessage { 55 | repeated float float_values = 1 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 56 | repeated double double_values = 2 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 57 | 58 | repeated int32 int32_values = 3 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 59 | repeated int64 int64_values = 4 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 60 | repeated uint32 uint32_values = 5 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 61 | repeated uint64 uint64_values = 6 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 62 | repeated sint32 sint32_values = 7 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 63 | repeated sint64 sint64_values = 8 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 64 | 65 | repeated fixed32 fixed32_values = 9 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 66 | repeated fixed64 fixed64_values = 10 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 67 | repeated sfixed32 sfixed32_values = 11 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 68 | repeated sfixed64 sfixed64_values = 12 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 69 | } 70 | 71 | message NotLoggingRepeatedNumberMessage { 72 | repeated float float_values = 1; 73 | repeated double double_values = 2; 74 | 75 | repeated int32 int32_values = 3; 76 | repeated int64 int64_values = 4; 77 | repeated uint32 uint32_values = 5; 78 | repeated uint64 uint64_values = 6; 79 | repeated sint32 sint32_values = 7; 80 | repeated sint64 sint64_values = 8; 81 | 82 | repeated fixed32 fixed32_values = 9; 83 | repeated fixed64 fixed64_values = 10; 84 | repeated sfixed32 sfixed32_values = 11; 85 | repeated sfixed64 sfixed64_values = 12; 86 | } 87 | 88 | message NestedMessage { 89 | message Nested { 90 | int32 int32_value = 1 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 91 | string string_value = 2 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 92 | } 93 | Nested nested_value = 1 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 94 | repeated Nested repeated_nested_values = 2 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 95 | } 96 | 97 | message NotLoggingNestedMessage { 98 | message Nested { 99 | int32 int32_value = 1; 100 | string string_value = 2; 101 | } 102 | Nested nested_value = 1; 103 | repeated Nested repeated_nested_values = 2; 104 | } 105 | 106 | message EnumMessage { 107 | NumericEnum numeric_enum_value = 1 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 108 | repeated NumericEnum repeated_numeric_enum_values = 2 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 109 | 110 | AliasedEnum aliased_enum_value = 3 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 111 | 112 | enum Nested { 113 | UNKNOWN = 0; 114 | PENDING = 1; 115 | COMPLETED = 2; 116 | } 117 | Nested nested_enum_value = 4 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 118 | repeated Nested repeated_nested_enum_values = 5 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 119 | } 120 | 121 | message NotLoggingEnumMessage { 122 | NumericEnum numeric_enum_value = 1; 123 | repeated NumericEnum repeated_numeric_enum_values = 2; 124 | 125 | AliasedEnum aliased_enum_value = 3; 126 | 127 | enum Nested { 128 | UNKNOWN = 0; 129 | PENDING = 1; 130 | COMPLETED = 2; 131 | } 132 | Nested nested_enum_value = 4; 133 | repeated Nested repeated_nested_enum_values = 5; 134 | } 135 | 136 | enum NumericEnum { 137 | ZERO = 0; 138 | ONE = 1; 139 | TWO = 2; 140 | } 141 | 142 | enum AliasedEnum { 143 | option allow_alias = true; 144 | UNKNOWN = 0; 145 | STARTED = 1; 146 | RUNNING = 1; 147 | } 148 | 149 | message Oneof { 150 | oneof oneof_value { 151 | int32 int32_value = 1 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 152 | string string_value = 2 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 153 | } 154 | } 155 | 156 | message OneofMessage { 157 | oneof oneof_value { 158 | int32 int32_value = 1 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 159 | string string_value = 2 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 160 | } 161 | 162 | repeated Oneof repeated_oneof_values = 3 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 163 | } 164 | 165 | message NotLoggingOneofMessage { 166 | oneof oneof_value { 167 | int32 int32_value = 1; 168 | string string_value = 2; 169 | } 170 | 171 | repeated Oneof repeated_oneof_values = 3; 172 | } 173 | 174 | message MapMessage { 175 | map mapped_value = 1 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 176 | map mapped_enum_value = 2 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 177 | map mapped_nested_value = 3 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 178 | } 179 | 180 | message NotLoggingMapMessage { 181 | map mapped_value = 1; 182 | map mapped_enum_value = 2; 183 | map mapped_nested_value = 3; 184 | } 185 | 186 | message JsonNameOptionMessage { 187 | string string_value = 1 [json_name="renamed_value", (kazegusuri.zap_mashaler.field) = {enabled: true}]; 188 | } 189 | 190 | message NotLoggingJsonNameOptionMessage { 191 | string string_value = 1 [json_name="renamed_value"]; 192 | } 193 | 194 | message WellKnownTypeMessage { 195 | google.protobuf.Duration duration = 1 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 196 | google.protobuf.Timestamp timestamp = 2 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 197 | } 198 | 199 | message NotLoggingWellKnownTypeMessage { 200 | google.protobuf.Duration duration = 1; 201 | google.protobuf.Timestamp timestamp = 2; 202 | } 203 | 204 | message MixedLoggingMessage { 205 | string string_value = 1 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 206 | bool bool_value = 2 [(kazegusuri.zap_mashaler.field) = {enabled: false}]; 207 | int32 int32_value = 3; 208 | } 209 | -------------------------------------------------------------------------------- /examples/zap-marshaler-secure/example.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package kazegusuri.zapmarshaler.example; 4 | option go_package = "examples"; 5 | 6 | import "zap_marshaler.proto"; 7 | import "google/protobuf/duration.proto"; 8 | import "google/protobuf/timestamp.proto"; 9 | 10 | message SimpleMessage { 11 | string string_value = 1 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 12 | bool bool_value = 2 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 13 | } 14 | 15 | message NotLoggingSimpleMessage { 16 | string string_value = 1; 17 | bool bool_value = 2; 18 | } 19 | 20 | message NumberMessage { 21 | float float_value = 1 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 22 | double double_value = 2 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 23 | 24 | int32 int32_value = 3 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 25 | int64 int64_value = 4 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 26 | uint32 uint32_value = 5 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 27 | uint64 uint64_value = 6 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 28 | sint32 sint32_value = 7 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 29 | sint64 sint64_value = 8 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 30 | 31 | fixed32 fixed32_value = 9 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 32 | fixed64 fixed64_value = 10 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 33 | sfixed32 sfixed32_value = 11 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 34 | sfixed64 sfixed64_value = 12 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 35 | } 36 | 37 | message NotLoggingNumberMessage { 38 | float float_value = 1; 39 | double double_value = 2; 40 | 41 | int32 int32_value = 3; 42 | int64 int64_value = 4; 43 | uint32 uint32_value = 5; 44 | uint64 uint64_value = 6; 45 | sint32 sint32_value = 7; 46 | sint64 sint64_value = 8; 47 | 48 | fixed32 fixed32_value = 9; 49 | fixed64 fixed64_value = 10; 50 | sfixed32 sfixed32_value = 11; 51 | sfixed64 sfixed64_value = 12; 52 | } 53 | 54 | message RepeatedNumberMessage { 55 | repeated float float_values = 1 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 56 | repeated double double_values = 2 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 57 | 58 | repeated int32 int32_values = 3 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 59 | repeated int64 int64_values = 4 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 60 | repeated uint32 uint32_values = 5 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 61 | repeated uint64 uint64_values = 6 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 62 | repeated sint32 sint32_values = 7 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 63 | repeated sint64 sint64_values = 8 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 64 | 65 | repeated fixed32 fixed32_values = 9 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 66 | repeated fixed64 fixed64_values = 10 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 67 | repeated sfixed32 sfixed32_values = 11 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 68 | repeated sfixed64 sfixed64_values = 12 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 69 | } 70 | 71 | message NotLoggingRepeatedNumberMessage { 72 | repeated float float_values = 1; 73 | repeated double double_values = 2; 74 | 75 | repeated int32 int32_values = 3; 76 | repeated int64 int64_values = 4; 77 | repeated uint32 uint32_values = 5; 78 | repeated uint64 uint64_values = 6; 79 | repeated sint32 sint32_values = 7; 80 | repeated sint64 sint64_values = 8; 81 | 82 | repeated fixed32 fixed32_values = 9; 83 | repeated fixed64 fixed64_values = 10; 84 | repeated sfixed32 sfixed32_values = 11; 85 | repeated sfixed64 sfixed64_values = 12; 86 | } 87 | 88 | message NestedMessage { 89 | message Nested { 90 | int32 int32_value = 1 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 91 | string string_value = 2 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 92 | } 93 | Nested nested_value = 1 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 94 | repeated Nested repeated_nested_values = 2 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 95 | } 96 | 97 | message NotLoggingNestedMessage { 98 | message Nested { 99 | int32 int32_value = 1; 100 | string string_value = 2; 101 | } 102 | Nested nested_value = 1; 103 | repeated Nested repeated_nested_values = 2; 104 | } 105 | 106 | message EnumMessage { 107 | NumericEnum numeric_enum_value = 1 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 108 | repeated NumericEnum repeated_numeric_enum_values = 2 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 109 | 110 | AliasedEnum aliased_enum_value = 3 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 111 | 112 | enum Nested { 113 | UNKNOWN = 0; 114 | PENDING = 1; 115 | COMPLETED = 2; 116 | } 117 | Nested nested_enum_value = 4 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 118 | repeated Nested repeated_nested_enum_values = 5 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 119 | } 120 | 121 | message NotLoggingEnumMessage { 122 | NumericEnum numeric_enum_value = 1; 123 | repeated NumericEnum repeated_numeric_enum_values = 2; 124 | 125 | AliasedEnum aliased_enum_value = 3; 126 | 127 | enum Nested { 128 | UNKNOWN = 0; 129 | PENDING = 1; 130 | COMPLETED = 2; 131 | } 132 | Nested nested_enum_value = 4; 133 | repeated Nested repeated_nested_enum_values = 5; 134 | } 135 | 136 | enum NumericEnum { 137 | ZERO = 0; 138 | ONE = 1; 139 | TWO = 2; 140 | } 141 | 142 | enum AliasedEnum { 143 | option allow_alias = true; 144 | UNKNOWN = 0; 145 | STARTED = 1; 146 | RUNNING = 1; 147 | } 148 | 149 | message Oneof { 150 | oneof oneof_value { 151 | int32 int32_value = 1 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 152 | string string_value = 2 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 153 | } 154 | } 155 | 156 | message OneofMessage { 157 | oneof oneof_value { 158 | int32 int32_value = 1 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 159 | string string_value = 2 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 160 | } 161 | 162 | repeated Oneof repeated_oneof_values = 3 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 163 | } 164 | 165 | message NotLoggingOneofMessage { 166 | oneof oneof_value { 167 | int32 int32_value = 1; 168 | string string_value = 2; 169 | } 170 | 171 | repeated Oneof repeated_oneof_values = 3; 172 | } 173 | 174 | message MapMessage { 175 | map mapped_value = 1 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 176 | map mapped_enum_value = 2 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 177 | map mapped_nested_value = 3 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 178 | } 179 | 180 | message NotLoggingMapMessage { 181 | map mapped_value = 1; 182 | map mapped_enum_value = 2; 183 | map mapped_nested_value = 3; 184 | } 185 | 186 | message JsonNameOptionMessage { 187 | string string_value = 1 [json_name="renamed_value", (kazegusuri.zap_mashaler.field) = {enabled: true}]; 188 | } 189 | 190 | message NotLoggingJsonNameOptionMessage { 191 | string string_value = 1 [json_name="renamed_value"]; 192 | } 193 | 194 | message WellKnownTypeMessage { 195 | google.protobuf.Duration duration = 1 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 196 | google.protobuf.Timestamp timestamp = 2 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 197 | } 198 | 199 | message NotLoggingWellKnownTypeMessage { 200 | google.protobuf.Duration duration = 1; 201 | google.protobuf.Timestamp timestamp = 2; 202 | } 203 | 204 | message MixedLoggingMessage { 205 | string string_value = 1 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 206 | bool bool_value = 2 [(kazegusuri.zap_mashaler.field) = {enabled: false}]; 207 | int32 int32_value = 3; 208 | } 209 | -------------------------------------------------------------------------------- /examples/zap-marshaler-secure/example.zap.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoc-gen-gogo. DO NOT EDIT. 2 | // source: examples/zap-marshaler-secure/example.proto 3 | 4 | package examples 5 | 6 | import go_uber_org_zap_zapcore "go.uber.org/zap/zapcore" 7 | import github_com_golang_protobuf_ptypes "github.com/golang/protobuf/ptypes" 8 | import proto "github.com/golang/protobuf/proto" 9 | import fmt "fmt" 10 | import math "math" 11 | import _ "github.com/golang/protobuf/ptypes/duration" 12 | import _ "github.com/golang/protobuf/ptypes/timestamp" 13 | import _ "github.com/kazegusuri/go-proto-zap-marshaler" 14 | 15 | // Reference imports to suppress errors if they are not otherwise used. 16 | var _ = proto.Marshal 17 | var _ = fmt.Errorf 18 | var _ = math.Inf 19 | 20 | func (m *SimpleMessage) MarshalLogObject(enc go_uber_org_zap_zapcore.ObjectEncoder) error { 21 | var keyName string 22 | _ = keyName 23 | 24 | keyName = "string_value" // field string_value = 1 25 | enc.AddString(keyName, m.StringValue) 26 | 27 | keyName = "bool_value" // field bool_value = 2 28 | enc.AddBool(keyName, m.BoolValue) 29 | 30 | return nil 31 | } 32 | 33 | func (m *NotLoggingSimpleMessage) MarshalLogObject(enc go_uber_org_zap_zapcore.ObjectEncoder) error { 34 | var keyName string 35 | _ = keyName 36 | 37 | return nil 38 | } 39 | 40 | func (m *NumberMessage) MarshalLogObject(enc go_uber_org_zap_zapcore.ObjectEncoder) error { 41 | var keyName string 42 | _ = keyName 43 | 44 | keyName = "float_value" // field float_value = 1 45 | enc.AddFloat32(keyName, m.FloatValue) 46 | 47 | keyName = "double_value" // field double_value = 2 48 | enc.AddFloat64(keyName, m.DoubleValue) 49 | 50 | keyName = "int32_value" // field int32_value = 3 51 | enc.AddInt32(keyName, m.Int32Value) 52 | 53 | keyName = "int64_value" // field int64_value = 4 54 | enc.AddInt64(keyName, m.Int64Value) 55 | 56 | keyName = "uint32_value" // field uint32_value = 5 57 | enc.AddUint32(keyName, m.Uint32Value) 58 | 59 | keyName = "uint64_value" // field uint64_value = 6 60 | enc.AddUint64(keyName, m.Uint64Value) 61 | 62 | keyName = "sint32_value" // field sint32_value = 7 63 | enc.AddInt32(keyName, m.Sint32Value) 64 | 65 | keyName = "sint64_value" // field sint64_value = 8 66 | enc.AddInt64(keyName, m.Sint64Value) 67 | 68 | keyName = "fixed32_value" // field fixed32_value = 9 69 | enc.AddUint32(keyName, m.Fixed32Value) 70 | 71 | keyName = "fixed64_value" // field fixed64_value = 10 72 | enc.AddUint64(keyName, m.Fixed64Value) 73 | 74 | keyName = "sfixed32_value" // field sfixed32_value = 11 75 | enc.AddInt32(keyName, m.Sfixed32Value) 76 | 77 | keyName = "sfixed64_value" // field sfixed64_value = 12 78 | enc.AddInt64(keyName, m.Sfixed64Value) 79 | 80 | return nil 81 | } 82 | 83 | func (m *NotLoggingNumberMessage) MarshalLogObject(enc go_uber_org_zap_zapcore.ObjectEncoder) error { 84 | var keyName string 85 | _ = keyName 86 | 87 | return nil 88 | } 89 | 90 | func (m *RepeatedNumberMessage) MarshalLogObject(enc go_uber_org_zap_zapcore.ObjectEncoder) error { 91 | var keyName string 92 | _ = keyName 93 | 94 | keyName = "float_values" // field float_values = 1 95 | enc.AddArray(keyName, go_uber_org_zap_zapcore.ArrayMarshalerFunc(func(aenc go_uber_org_zap_zapcore.ArrayEncoder) error { 96 | for _, rv := range m.FloatValues { 97 | _ = rv 98 | aenc.AppendFloat32(rv) 99 | } 100 | return nil 101 | })) 102 | 103 | keyName = "double_values" // field double_values = 2 104 | enc.AddArray(keyName, go_uber_org_zap_zapcore.ArrayMarshalerFunc(func(aenc go_uber_org_zap_zapcore.ArrayEncoder) error { 105 | for _, rv := range m.DoubleValues { 106 | _ = rv 107 | aenc.AppendFloat64(rv) 108 | } 109 | return nil 110 | })) 111 | 112 | keyName = "int32_values" // field int32_values = 3 113 | enc.AddArray(keyName, go_uber_org_zap_zapcore.ArrayMarshalerFunc(func(aenc go_uber_org_zap_zapcore.ArrayEncoder) error { 114 | for _, rv := range m.Int32Values { 115 | _ = rv 116 | aenc.AppendInt32(rv) 117 | } 118 | return nil 119 | })) 120 | 121 | keyName = "int64_values" // field int64_values = 4 122 | enc.AddArray(keyName, go_uber_org_zap_zapcore.ArrayMarshalerFunc(func(aenc go_uber_org_zap_zapcore.ArrayEncoder) error { 123 | for _, rv := range m.Int64Values { 124 | _ = rv 125 | aenc.AppendInt64(rv) 126 | } 127 | return nil 128 | })) 129 | 130 | keyName = "uint32_values" // field uint32_values = 5 131 | enc.AddArray(keyName, go_uber_org_zap_zapcore.ArrayMarshalerFunc(func(aenc go_uber_org_zap_zapcore.ArrayEncoder) error { 132 | for _, rv := range m.Uint32Values { 133 | _ = rv 134 | aenc.AppendUint32(rv) 135 | } 136 | return nil 137 | })) 138 | 139 | keyName = "uint64_values" // field uint64_values = 6 140 | enc.AddArray(keyName, go_uber_org_zap_zapcore.ArrayMarshalerFunc(func(aenc go_uber_org_zap_zapcore.ArrayEncoder) error { 141 | for _, rv := range m.Uint64Values { 142 | _ = rv 143 | aenc.AppendUint64(rv) 144 | } 145 | return nil 146 | })) 147 | 148 | keyName = "sint32_values" // field sint32_values = 7 149 | enc.AddArray(keyName, go_uber_org_zap_zapcore.ArrayMarshalerFunc(func(aenc go_uber_org_zap_zapcore.ArrayEncoder) error { 150 | for _, rv := range m.Sint32Values { 151 | _ = rv 152 | aenc.AppendInt32(rv) 153 | } 154 | return nil 155 | })) 156 | 157 | keyName = "sint64_values" // field sint64_values = 8 158 | enc.AddArray(keyName, go_uber_org_zap_zapcore.ArrayMarshalerFunc(func(aenc go_uber_org_zap_zapcore.ArrayEncoder) error { 159 | for _, rv := range m.Sint64Values { 160 | _ = rv 161 | aenc.AppendInt64(rv) 162 | } 163 | return nil 164 | })) 165 | 166 | keyName = "fixed32_values" // field fixed32_values = 9 167 | enc.AddArray(keyName, go_uber_org_zap_zapcore.ArrayMarshalerFunc(func(aenc go_uber_org_zap_zapcore.ArrayEncoder) error { 168 | for _, rv := range m.Fixed32Values { 169 | _ = rv 170 | aenc.AppendUint32(rv) 171 | } 172 | return nil 173 | })) 174 | 175 | keyName = "fixed64_values" // field fixed64_values = 10 176 | enc.AddArray(keyName, go_uber_org_zap_zapcore.ArrayMarshalerFunc(func(aenc go_uber_org_zap_zapcore.ArrayEncoder) error { 177 | for _, rv := range m.Fixed64Values { 178 | _ = rv 179 | aenc.AppendUint64(rv) 180 | } 181 | return nil 182 | })) 183 | 184 | keyName = "sfixed32_values" // field sfixed32_values = 11 185 | enc.AddArray(keyName, go_uber_org_zap_zapcore.ArrayMarshalerFunc(func(aenc go_uber_org_zap_zapcore.ArrayEncoder) error { 186 | for _, rv := range m.Sfixed32Values { 187 | _ = rv 188 | aenc.AppendInt32(rv) 189 | } 190 | return nil 191 | })) 192 | 193 | keyName = "sfixed64_values" // field sfixed64_values = 12 194 | enc.AddArray(keyName, go_uber_org_zap_zapcore.ArrayMarshalerFunc(func(aenc go_uber_org_zap_zapcore.ArrayEncoder) error { 195 | for _, rv := range m.Sfixed64Values { 196 | _ = rv 197 | aenc.AppendInt64(rv) 198 | } 199 | return nil 200 | })) 201 | 202 | return nil 203 | } 204 | 205 | func (m *NotLoggingRepeatedNumberMessage) MarshalLogObject(enc go_uber_org_zap_zapcore.ObjectEncoder) error { 206 | var keyName string 207 | _ = keyName 208 | 209 | return nil 210 | } 211 | 212 | func (m *NestedMessage) MarshalLogObject(enc go_uber_org_zap_zapcore.ObjectEncoder) error { 213 | var keyName string 214 | _ = keyName 215 | 216 | keyName = "nested_value" // field nested_value = 1 217 | if m.NestedValue != nil { 218 | var vv interface{} = m.NestedValue 219 | if marshaler, ok := vv.(go_uber_org_zap_zapcore.ObjectMarshaler); ok { 220 | enc.AddObject(keyName, marshaler) 221 | } 222 | } 223 | 224 | keyName = "repeated_nested_values" // field repeated_nested_values = 2 225 | enc.AddArray(keyName, go_uber_org_zap_zapcore.ArrayMarshalerFunc(func(aenc go_uber_org_zap_zapcore.ArrayEncoder) error { 226 | for _, rv := range m.RepeatedNestedValues { 227 | _ = rv 228 | if rv != nil { 229 | var vv interface{} = rv 230 | if marshaler, ok := vv.(go_uber_org_zap_zapcore.ObjectMarshaler); ok { 231 | aenc.AppendObject(marshaler) 232 | } 233 | } 234 | } 235 | return nil 236 | })) 237 | 238 | return nil 239 | } 240 | 241 | func (m *NestedMessage_Nested) MarshalLogObject(enc go_uber_org_zap_zapcore.ObjectEncoder) error { 242 | var keyName string 243 | _ = keyName 244 | 245 | keyName = "int32_value" // field int32_value = 1 246 | enc.AddInt32(keyName, m.Int32Value) 247 | 248 | keyName = "string_value" // field string_value = 2 249 | enc.AddString(keyName, m.StringValue) 250 | 251 | return nil 252 | } 253 | 254 | func (m *NotLoggingNestedMessage) MarshalLogObject(enc go_uber_org_zap_zapcore.ObjectEncoder) error { 255 | var keyName string 256 | _ = keyName 257 | 258 | return nil 259 | } 260 | 261 | func (m *NotLoggingNestedMessage_Nested) MarshalLogObject(enc go_uber_org_zap_zapcore.ObjectEncoder) error { 262 | var keyName string 263 | _ = keyName 264 | 265 | return nil 266 | } 267 | 268 | func (m *EnumMessage) MarshalLogObject(enc go_uber_org_zap_zapcore.ObjectEncoder) error { 269 | var keyName string 270 | _ = keyName 271 | 272 | keyName = "numeric_enum_value" // field numeric_enum_value = 1 273 | enc.AddString(keyName, m.NumericEnumValue.String()) 274 | 275 | keyName = "repeated_numeric_enum_values" // field repeated_numeric_enum_values = 2 276 | enc.AddArray(keyName, go_uber_org_zap_zapcore.ArrayMarshalerFunc(func(aenc go_uber_org_zap_zapcore.ArrayEncoder) error { 277 | for _, rv := range m.RepeatedNumericEnumValues { 278 | _ = rv 279 | aenc.AppendString(rv.String()) 280 | } 281 | return nil 282 | })) 283 | 284 | keyName = "aliased_enum_value" // field aliased_enum_value = 3 285 | enc.AddString(keyName, m.AliasedEnumValue.String()) 286 | 287 | keyName = "nested_enum_value" // field nested_enum_value = 4 288 | enc.AddString(keyName, m.NestedEnumValue.String()) 289 | 290 | keyName = "repeated_nested_enum_values" // field repeated_nested_enum_values = 5 291 | enc.AddArray(keyName, go_uber_org_zap_zapcore.ArrayMarshalerFunc(func(aenc go_uber_org_zap_zapcore.ArrayEncoder) error { 292 | for _, rv := range m.RepeatedNestedEnumValues { 293 | _ = rv 294 | aenc.AppendString(rv.String()) 295 | } 296 | return nil 297 | })) 298 | 299 | return nil 300 | } 301 | 302 | func (m *NotLoggingEnumMessage) MarshalLogObject(enc go_uber_org_zap_zapcore.ObjectEncoder) error { 303 | var keyName string 304 | _ = keyName 305 | 306 | return nil 307 | } 308 | 309 | func (m *Oneof) MarshalLogObject(enc go_uber_org_zap_zapcore.ObjectEncoder) error { 310 | var keyName string 311 | _ = keyName 312 | 313 | keyName = "int32_value" // field int32_value = 1 314 | if ov, ok := m.GetOneofValue().(*Oneof_Int32Value); ok { 315 | _ = ov 316 | enc.AddInt32(keyName, ov.Int32Value) 317 | } 318 | 319 | keyName = "string_value" // field string_value = 2 320 | if ov, ok := m.GetOneofValue().(*Oneof_StringValue); ok { 321 | _ = ov 322 | enc.AddString(keyName, ov.StringValue) 323 | } 324 | 325 | return nil 326 | } 327 | 328 | func (m *OneofMessage) MarshalLogObject(enc go_uber_org_zap_zapcore.ObjectEncoder) error { 329 | var keyName string 330 | _ = keyName 331 | 332 | keyName = "int32_value" // field int32_value = 1 333 | if ov, ok := m.GetOneofValue().(*OneofMessage_Int32Value); ok { 334 | _ = ov 335 | enc.AddInt32(keyName, ov.Int32Value) 336 | } 337 | 338 | keyName = "string_value" // field string_value = 2 339 | if ov, ok := m.GetOneofValue().(*OneofMessage_StringValue); ok { 340 | _ = ov 341 | enc.AddString(keyName, ov.StringValue) 342 | } 343 | 344 | keyName = "repeated_oneof_values" // field repeated_oneof_values = 3 345 | enc.AddArray(keyName, go_uber_org_zap_zapcore.ArrayMarshalerFunc(func(aenc go_uber_org_zap_zapcore.ArrayEncoder) error { 346 | for _, rv := range m.RepeatedOneofValues { 347 | _ = rv 348 | if rv != nil { 349 | var vv interface{} = rv 350 | if marshaler, ok := vv.(go_uber_org_zap_zapcore.ObjectMarshaler); ok { 351 | aenc.AppendObject(marshaler) 352 | } 353 | } 354 | } 355 | return nil 356 | })) 357 | 358 | return nil 359 | } 360 | 361 | func (m *NotLoggingOneofMessage) MarshalLogObject(enc go_uber_org_zap_zapcore.ObjectEncoder) error { 362 | var keyName string 363 | _ = keyName 364 | 365 | return nil 366 | } 367 | 368 | func (m *MapMessage) MarshalLogObject(enc go_uber_org_zap_zapcore.ObjectEncoder) error { 369 | var keyName string 370 | _ = keyName 371 | 372 | keyName = "mapped_value" // field mapped_value = 1 373 | enc.AddObject(keyName, go_uber_org_zap_zapcore.ObjectMarshalerFunc(func(enc go_uber_org_zap_zapcore.ObjectEncoder) error { 374 | for mk, mv := range m.MappedValue { 375 | key := fmt.Sprint(mk) 376 | _ = key 377 | enc.AddString(key, mv) 378 | } 379 | return nil 380 | })) 381 | 382 | keyName = "mapped_enum_value" // field mapped_enum_value = 2 383 | enc.AddObject(keyName, go_uber_org_zap_zapcore.ObjectMarshalerFunc(func(enc go_uber_org_zap_zapcore.ObjectEncoder) error { 384 | for mk, mv := range m.MappedEnumValue { 385 | key := mk 386 | _ = key 387 | enc.AddString(key, mv.String()) 388 | } 389 | return nil 390 | })) 391 | 392 | keyName = "mapped_nested_value" // field mapped_nested_value = 3 393 | enc.AddObject(keyName, go_uber_org_zap_zapcore.ObjectMarshalerFunc(func(enc go_uber_org_zap_zapcore.ObjectEncoder) error { 394 | for mk, mv := range m.MappedNestedValue { 395 | key := mk 396 | _ = key 397 | if mv != nil { 398 | var vv interface{} = mv 399 | if marshaler, ok := vv.(go_uber_org_zap_zapcore.ObjectMarshaler); ok { 400 | enc.AddObject(key, marshaler) 401 | } 402 | } 403 | } 404 | return nil 405 | })) 406 | 407 | return nil 408 | } 409 | 410 | func (m *NotLoggingMapMessage) MarshalLogObject(enc go_uber_org_zap_zapcore.ObjectEncoder) error { 411 | var keyName string 412 | _ = keyName 413 | 414 | return nil 415 | } 416 | 417 | func (m *JsonNameOptionMessage) MarshalLogObject(enc go_uber_org_zap_zapcore.ObjectEncoder) error { 418 | var keyName string 419 | _ = keyName 420 | 421 | keyName = "string_value" // field string_value = 1 422 | enc.AddString(keyName, m.StringValue) 423 | 424 | return nil 425 | } 426 | 427 | func (m *NotLoggingJsonNameOptionMessage) MarshalLogObject(enc go_uber_org_zap_zapcore.ObjectEncoder) error { 428 | var keyName string 429 | _ = keyName 430 | 431 | return nil 432 | } 433 | 434 | func (m *WellKnownTypeMessage) MarshalLogObject(enc go_uber_org_zap_zapcore.ObjectEncoder) error { 435 | var keyName string 436 | _ = keyName 437 | 438 | keyName = "duration" // field duration = 1 439 | if d, err := github_com_golang_protobuf_ptypes.Duration(m.Duration); err == nil { 440 | enc.AddDuration(keyName, d) 441 | } 442 | 443 | keyName = "timestamp" // field timestamp = 2 444 | if t, err := github_com_golang_protobuf_ptypes.Timestamp(m.Timestamp); err == nil { 445 | enc.AddTime(keyName, t) 446 | } 447 | 448 | return nil 449 | } 450 | 451 | func (m *NotLoggingWellKnownTypeMessage) MarshalLogObject(enc go_uber_org_zap_zapcore.ObjectEncoder) error { 452 | var keyName string 453 | _ = keyName 454 | 455 | return nil 456 | } 457 | 458 | func (m *MixedLoggingMessage) MarshalLogObject(enc go_uber_org_zap_zapcore.ObjectEncoder) error { 459 | var keyName string 460 | _ = keyName 461 | 462 | keyName = "string_value" // field string_value = 1 463 | enc.AddString(keyName, m.StringValue) 464 | 465 | return nil 466 | } 467 | -------------------------------------------------------------------------------- /examples/zap-marshaler-secure/example_test.go: -------------------------------------------------------------------------------- 1 | package examples 2 | 3 | import ( 4 | "time" 5 | 6 | "github.com/golang/protobuf/ptypes" 7 | "go.uber.org/zap" 8 | ) 9 | 10 | func ExampleTest() { 11 | l := zap.NewExample() 12 | l.Info("test", zap.Object("simple", &SimpleMessage{ 13 | StringValue: "xyz", 14 | BoolValue: true, 15 | })) 16 | // output: {"level":"info","msg":"test","simple":{"string_value":"xyz","bool_value":true}} 17 | } 18 | 19 | func ExampleNotLoggingTest() { 20 | l := zap.NewExample() 21 | l.Info("test", zap.Object("simple", &NotLoggingSimpleMessage{ 22 | StringValue: "xyz", 23 | BoolValue: true, 24 | })) 25 | // output: {"level":"info","msg":"test","simple":{}} 26 | } 27 | 28 | func ExampleNumberMessage() { 29 | l := zap.NewExample() 30 | l.Info("test", zap.Object("number", &NumberMessage{ 31 | FloatValue: 0.5, 32 | DoubleValue: 2.2, 33 | Int32Value: -3, 34 | Int64Value: -4, 35 | Uint32Value: 5, 36 | Uint64Value: 6, 37 | Sint32Value: -7, 38 | Sint64Value: -8, 39 | Fixed32Value: 9, 40 | Fixed64Value: 10, 41 | Sfixed32Value: -11, 42 | Sfixed64Value: -12, 43 | })) 44 | // output: {"level":"info","msg":"test","number":{"float_value":0.5,"double_value":2.2,"int32_value":-3,"int64_value":-4,"uint32_value":5,"uint64_value":6,"sint32_value":-7,"sint64_value":-8,"fixed32_value":9,"fixed64_value":10,"sfixed32_value":-11,"sfixed64_value":-12}} 45 | } 46 | 47 | func ExampleNotLoggingNumberMessage() { 48 | l := zap.NewExample() 49 | l.Info("test", zap.Object("number", &NotLoggingNumberMessage{ 50 | FloatValue: 0.5, 51 | DoubleValue: 2.2, 52 | Int32Value: -3, 53 | Int64Value: -4, 54 | Uint32Value: 5, 55 | Uint64Value: 6, 56 | Sint32Value: -7, 57 | Sint64Value: -8, 58 | Fixed32Value: 9, 59 | Fixed64Value: 10, 60 | Sfixed32Value: -11, 61 | Sfixed64Value: -12, 62 | })) 63 | // output: {"level":"info","msg":"test","number":{}} 64 | } 65 | 66 | func ExampleRepeatedNumberMessage() { 67 | l := zap.NewExample() 68 | l.Info("test", zap.Object("number", &RepeatedNumberMessage{ 69 | FloatValues: []float32{0.5, 1}, 70 | DoubleValues: []float64{2.2, 1}, 71 | Int32Values: []int32{-3, 3}, 72 | Int64Values: []int64{-4, 4}, 73 | Uint32Values: []uint32{5, 55}, 74 | Uint64Values: []uint64{6, 66}, 75 | Sint32Values: []int32{-7, 7}, 76 | Sint64Values: []int64{-8, 8}, 77 | Fixed32Values: []uint32{9, 99}, 78 | Fixed64Values: []uint64{10, 100}, 79 | Sfixed32Values: []int32{-11, 11}, 80 | Sfixed64Values: []int64{-12, 12}, 81 | })) 82 | // output: {"level":"info","msg":"test","number":{"float_values":[0.5,1],"double_values":[2.2,1],"int32_values":[-3,3],"int64_values":[-4,4],"uint32_values":[5,55],"uint64_values":[6,66],"sint32_values":[-7,7],"sint64_values":[-8,8],"fixed32_values":[9,99],"fixed64_values":[10,100],"sfixed32_values":[-11,11],"sfixed64_values":[-12,12]}} 83 | } 84 | 85 | func ExampleNotLoggingRepeatedNumberMessage() { 86 | l := zap.NewExample() 87 | l.Info("test", zap.Object("number", &NotLoggingRepeatedNumberMessage{ 88 | FloatValues: []float32{0.5, 1}, 89 | DoubleValues: []float64{2.2, 1}, 90 | Int32Values: []int32{-3, 3}, 91 | Int64Values: []int64{-4, 4}, 92 | Uint32Values: []uint32{5, 55}, 93 | Uint64Values: []uint64{6, 66}, 94 | Sint32Values: []int32{-7, 7}, 95 | Sint64Values: []int64{-8, 8}, 96 | Fixed32Values: []uint32{9, 99}, 97 | Fixed64Values: []uint64{10, 100}, 98 | Sfixed32Values: []int32{-11, 11}, 99 | Sfixed64Values: []int64{-12, 12}, 100 | })) 101 | // output: {"level":"info","msg":"test","number":{}} 102 | } 103 | 104 | func ExampleNestedMessage() { 105 | l := zap.NewExample() 106 | l.Info("test", zap.Object("nested", &NestedMessage{ 107 | NestedValue: &NestedMessage_Nested{ 108 | Int32Value: 100, 109 | StringValue: "xxx", 110 | }, 111 | RepeatedNestedValues: []*NestedMessage_Nested{ 112 | { 113 | Int32Value: 200, 114 | StringValue: "yyy", 115 | }, 116 | { 117 | Int32Value: 300, 118 | StringValue: "zzz", 119 | }, 120 | }, 121 | })) 122 | // output: {"level":"info","msg":"test","nested":{"nested_value":{"int32_value":100,"string_value":"xxx"},"repeated_nested_values":[{"int32_value":200,"string_value":"yyy"},{"int32_value":300,"string_value":"zzz"}]}} 123 | } 124 | 125 | func ExampleNotLoggingNestedMessage() { 126 | l := zap.NewExample() 127 | l.Info("test", zap.Object("nested", &NotLoggingNestedMessage{ 128 | NestedValue: &NotLoggingNestedMessage_Nested{ 129 | Int32Value: 100, 130 | StringValue: "xxx", 131 | }, 132 | RepeatedNestedValues: []*NotLoggingNestedMessage_Nested{ 133 | { 134 | Int32Value: 200, 135 | StringValue: "yyy", 136 | }, 137 | { 138 | Int32Value: 300, 139 | StringValue: "zzz", 140 | }, 141 | }, 142 | })) 143 | // output: {"level":"info","msg":"test","nested":{}} 144 | } 145 | 146 | func ExampleEnumMessage() { 147 | l := zap.NewExample() 148 | l.Info("test", zap.Object("enum", &EnumMessage{ 149 | NumericEnumValue: NumericEnum_ONE, 150 | RepeatedNumericEnumValues: []NumericEnum{ 151 | NumericEnum_ONE, 152 | NumericEnum_TWO, 153 | }, 154 | AliasedEnumValue: AliasedEnum_RUNNING, 155 | NestedEnumValue: EnumMessage_PENDING, 156 | RepeatedNestedEnumValues: []EnumMessage_Nested{ 157 | EnumMessage_PENDING, 158 | EnumMessage_COMPLETED, 159 | }, 160 | })) 161 | // output: {"level":"info","msg":"test","enum":{"numeric_enum_value":"ONE","repeated_numeric_enum_values":["ONE","TWO"],"aliased_enum_value":"STARTED","nested_enum_value":"PENDING","repeated_nested_enum_values":["PENDING","COMPLETED"]}} 162 | } 163 | 164 | func ExampleNotLoggingEnumMessage() { 165 | l := zap.NewExample() 166 | l.Info("test", zap.Object("enum", &NotLoggingEnumMessage{ 167 | NumericEnumValue: NumericEnum_ONE, 168 | RepeatedNumericEnumValues: []NumericEnum{ 169 | NumericEnum_ONE, 170 | NumericEnum_TWO, 171 | }, 172 | AliasedEnumValue: AliasedEnum_RUNNING, 173 | NestedEnumValue: NotLoggingEnumMessage_PENDING, 174 | RepeatedNestedEnumValues: []NotLoggingEnumMessage_Nested{ 175 | NotLoggingEnumMessage_PENDING, 176 | NotLoggingEnumMessage_COMPLETED, 177 | }, 178 | })) 179 | // output: {"level":"info","msg":"test","enum":{}} 180 | } 181 | 182 | func ExampleOneofMessage() { 183 | l := zap.NewExample() 184 | l.Info("test", zap.Object("oneof", &OneofMessage{ 185 | OneofValue: &OneofMessage_Int32Value{Int32Value: 1000}, 186 | RepeatedOneofValues: []*Oneof{ 187 | { 188 | OneofValue: &Oneof_Int32Value{Int32Value: 1000}, 189 | }, 190 | { 191 | OneofValue: &Oneof_StringValue{StringValue: "xyz"}, 192 | }, 193 | }, 194 | })) 195 | // output: {"level":"info","msg":"test","oneof":{"int32_value":1000,"repeated_oneof_values":[{"int32_value":1000},{"string_value":"xyz"}]}} 196 | } 197 | 198 | func ExampleNotLoggingOneofMessage() { 199 | l := zap.NewExample() 200 | l.Info("test", zap.Object("oneof", &NotLoggingOneofMessage{ 201 | OneofValue: &NotLoggingOneofMessage_Int32Value{Int32Value: 1000}, 202 | RepeatedOneofValues: []*Oneof{ 203 | { 204 | OneofValue: &Oneof_Int32Value{Int32Value: 1000}, 205 | }, 206 | { 207 | OneofValue: &Oneof_StringValue{StringValue: "xyz"}, 208 | }, 209 | }, 210 | })) 211 | // output: {"level":"info","msg":"test","oneof":{}} 212 | } 213 | 214 | func ExampleMapMessage() { 215 | l := zap.NewExample() 216 | l.Info("test", zap.Object("map", &MapMessage{ 217 | MappedValue: map[int32]string{ 218 | 1: "foo", 219 | 2: "bar", 220 | }, 221 | MappedEnumValue: map[string]NumericEnum{ 222 | "one": NumericEnum_ONE, 223 | "two": NumericEnum_TWO, 224 | }, 225 | MappedNestedValue: map[string]*NestedMessage{ 226 | "foo": &NestedMessage{ 227 | NestedValue: &NestedMessage_Nested{ 228 | Int32Value: 100, 229 | StringValue: "xxx", 230 | }, 231 | RepeatedNestedValues: []*NestedMessage_Nested{ 232 | { 233 | Int32Value: 200, 234 | StringValue: "yyy", 235 | }, 236 | { 237 | Int32Value: 300, 238 | StringValue: "zzz", 239 | }, 240 | }, 241 | }, 242 | }, 243 | })) 244 | // output: {"level":"info","msg":"test","map":{"mapped_value":{"1":"foo","2":"bar"},"mapped_enum_value":{"one":"ONE","two":"TWO"},"mapped_nested_value":{"foo":{"nested_value":{"int32_value":100,"string_value":"xxx"},"repeated_nested_values":[{"int32_value":200,"string_value":"yyy"},{"int32_value":300,"string_value":"zzz"}]}}}} 245 | } 246 | 247 | func ExampleNotLoggingMapMessage() { 248 | l := zap.NewExample() 249 | l.Info("test", zap.Object("map", &NotLoggingMapMessage{ 250 | MappedValue: map[int32]string{ 251 | 1: "foo", 252 | 2: "bar", 253 | }, 254 | MappedEnumValue: map[string]NumericEnum{ 255 | "one": NumericEnum_ONE, 256 | "two": NumericEnum_TWO, 257 | }, 258 | MappedNestedValue: map[string]*NestedMessage{ 259 | "foo": &NestedMessage{ 260 | NestedValue: &NestedMessage_Nested{ 261 | Int32Value: 100, 262 | StringValue: "xxx", 263 | }, 264 | RepeatedNestedValues: []*NestedMessage_Nested{ 265 | { 266 | Int32Value: 200, 267 | StringValue: "yyy", 268 | }, 269 | { 270 | Int32Value: 300, 271 | StringValue: "zzz", 272 | }, 273 | }, 274 | }, 275 | }, 276 | })) 277 | // output: {"level":"info","msg":"test","map":{}} 278 | } 279 | 280 | func ExampleJsonNameOptionMessage() { 281 | l := zap.NewExample() 282 | l.Info("test", zap.Object("json_name", &JsonNameOptionMessage{ 283 | StringValue: "xxx", 284 | })) 285 | // output: {"level":"info","msg":"test","json_name":{"string_value":"xxx"}} 286 | } 287 | 288 | func ExampleNotLoggingJsonNameOptionMessage() { 289 | l := zap.NewExample() 290 | l.Info("test", zap.Object("json_name", &NotLoggingJsonNameOptionMessage{ 291 | StringValue: "xxx", 292 | })) 293 | // output: {"level":"info","msg":"test","json_name":{}} 294 | } 295 | 296 | func ExampleWellKnownTypeMessage() { 297 | d := ptypes.DurationProto(10 * time.Minute) 298 | t, _ := ptypes.TimestampProto(time.Unix(1502533013, 125892275)) 299 | l := zap.NewExample() 300 | l.Info("test", zap.Object("wkt", &WellKnownTypeMessage{ 301 | Duration: d, 302 | Timestamp: t, 303 | })) 304 | // output: {"level":"info","msg":"test","wkt":{"duration":"10m0s","timestamp":"2017-08-12T10:16:53.125Z"}} 305 | } 306 | 307 | func ExampleNotLoggingWellKnownTypeMessage() { 308 | d := ptypes.DurationProto(10 * time.Minute) 309 | t, _ := ptypes.TimestampProto(time.Unix(1502533013, 125892275)) 310 | l := zap.NewExample() 311 | l.Info("test", zap.Object("wkt", &NotLoggingWellKnownTypeMessage{ 312 | Duration: d, 313 | Timestamp: t, 314 | })) 315 | // output: {"level":"info","msg":"test","wkt":{}} 316 | } 317 | 318 | func ExampleMixedLoggingMessage() { 319 | l := zap.NewExample() 320 | l.Info("test", zap.Object("mlm", &MixedLoggingMessage{ 321 | StringValue: "xxx", 322 | BoolValue: true, 323 | Int32Value: 1, 324 | })) 325 | // output: {"level":"info","msg":"test","mlm":{"string_value":"xxx"}} 326 | } 327 | 328 | func ExampleTestWithNilField() { 329 | l := zap.NewExample() 330 | sl := l.Sugar() 331 | var sm *SimpleMessage = nil 332 | sl = sl.With("SimpleMessage", sm) 333 | sl.Infow("test") 334 | // output: {"level":"info","msg":"test","SimpleMessage":{}} 335 | } 336 | -------------------------------------------------------------------------------- /examples/zap-marshaler/example.pb.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoc-gen-go. DO NOT EDIT. 2 | // source: examples/zap-marshaler/example.proto 3 | 4 | package examples 5 | 6 | import ( 7 | fmt "fmt" 8 | proto "github.com/golang/protobuf/proto" 9 | duration "github.com/golang/protobuf/ptypes/duration" 10 | timestamp "github.com/golang/protobuf/ptypes/timestamp" 11 | _ "github.com/kazegusuri/go-proto-zap-marshaler" 12 | math "math" 13 | ) 14 | 15 | // Reference imports to suppress errors if they are not otherwise used. 16 | var _ = proto.Marshal 17 | var _ = fmt.Errorf 18 | var _ = math.Inf 19 | 20 | // This is a compile-time assertion to ensure that this generated file 21 | // is compatible with the proto package it is being compiled against. 22 | // A compilation error at this line likely means your copy of the 23 | // proto package needs to be updated. 24 | const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package 25 | 26 | type NumericEnum int32 27 | 28 | const ( 29 | NumericEnum_ZERO NumericEnum = 0 30 | NumericEnum_ONE NumericEnum = 1 31 | NumericEnum_TWO NumericEnum = 2 32 | ) 33 | 34 | var NumericEnum_name = map[int32]string{ 35 | 0: "ZERO", 36 | 1: "ONE", 37 | 2: "TWO", 38 | } 39 | 40 | var NumericEnum_value = map[string]int32{ 41 | "ZERO": 0, 42 | "ONE": 1, 43 | "TWO": 2, 44 | } 45 | 46 | func (x NumericEnum) String() string { 47 | return proto.EnumName(NumericEnum_name, int32(x)) 48 | } 49 | 50 | func (NumericEnum) EnumDescriptor() ([]byte, []int) { 51 | return fileDescriptor_722e198d308550d7, []int{0} 52 | } 53 | 54 | type AliasedEnum int32 55 | 56 | const ( 57 | AliasedEnum_UNKNOWN AliasedEnum = 0 58 | AliasedEnum_STARTED AliasedEnum = 1 59 | AliasedEnum_RUNNING AliasedEnum = 1 60 | ) 61 | 62 | var AliasedEnum_name = map[int32]string{ 63 | 0: "UNKNOWN", 64 | 1: "STARTED", 65 | // Duplicate value: 1: "RUNNING", 66 | } 67 | 68 | var AliasedEnum_value = map[string]int32{ 69 | "UNKNOWN": 0, 70 | "STARTED": 1, 71 | "RUNNING": 1, 72 | } 73 | 74 | func (x AliasedEnum) String() string { 75 | return proto.EnumName(AliasedEnum_name, int32(x)) 76 | } 77 | 78 | func (AliasedEnum) EnumDescriptor() ([]byte, []int) { 79 | return fileDescriptor_722e198d308550d7, []int{1} 80 | } 81 | 82 | type EnumMessage_Nested int32 83 | 84 | const ( 85 | EnumMessage_UNKNOWN EnumMessage_Nested = 0 86 | EnumMessage_PENDING EnumMessage_Nested = 1 87 | EnumMessage_COMPLETED EnumMessage_Nested = 2 88 | ) 89 | 90 | var EnumMessage_Nested_name = map[int32]string{ 91 | 0: "UNKNOWN", 92 | 1: "PENDING", 93 | 2: "COMPLETED", 94 | } 95 | 96 | var EnumMessage_Nested_value = map[string]int32{ 97 | "UNKNOWN": 0, 98 | "PENDING": 1, 99 | "COMPLETED": 2, 100 | } 101 | 102 | func (x EnumMessage_Nested) String() string { 103 | return proto.EnumName(EnumMessage_Nested_name, int32(x)) 104 | } 105 | 106 | func (EnumMessage_Nested) EnumDescriptor() ([]byte, []int) { 107 | return fileDescriptor_722e198d308550d7, []int{8, 0} 108 | } 109 | 110 | type NotLoggingEnumMessage_Nested int32 111 | 112 | const ( 113 | NotLoggingEnumMessage_UNKNOWN NotLoggingEnumMessage_Nested = 0 114 | NotLoggingEnumMessage_PENDING NotLoggingEnumMessage_Nested = 1 115 | NotLoggingEnumMessage_COMPLETED NotLoggingEnumMessage_Nested = 2 116 | ) 117 | 118 | var NotLoggingEnumMessage_Nested_name = map[int32]string{ 119 | 0: "UNKNOWN", 120 | 1: "PENDING", 121 | 2: "COMPLETED", 122 | } 123 | 124 | var NotLoggingEnumMessage_Nested_value = map[string]int32{ 125 | "UNKNOWN": 0, 126 | "PENDING": 1, 127 | "COMPLETED": 2, 128 | } 129 | 130 | func (x NotLoggingEnumMessage_Nested) String() string { 131 | return proto.EnumName(NotLoggingEnumMessage_Nested_name, int32(x)) 132 | } 133 | 134 | func (NotLoggingEnumMessage_Nested) EnumDescriptor() ([]byte, []int) { 135 | return fileDescriptor_722e198d308550d7, []int{9, 0} 136 | } 137 | 138 | type SimpleMessage struct { 139 | StringValue string `protobuf:"bytes,1,opt,name=string_value,json=stringValue,proto3" json:"string_value,omitempty"` 140 | BoolValue bool `protobuf:"varint,2,opt,name=bool_value,json=boolValue,proto3" json:"bool_value,omitempty"` 141 | XXX_NoUnkeyedLiteral struct{} `json:"-"` 142 | XXX_unrecognized []byte `json:"-"` 143 | XXX_sizecache int32 `json:"-"` 144 | } 145 | 146 | func (m *SimpleMessage) Reset() { *m = SimpleMessage{} } 147 | func (m *SimpleMessage) String() string { return proto.CompactTextString(m) } 148 | func (*SimpleMessage) ProtoMessage() {} 149 | func (*SimpleMessage) Descriptor() ([]byte, []int) { 150 | return fileDescriptor_722e198d308550d7, []int{0} 151 | } 152 | 153 | func (m *SimpleMessage) XXX_Unmarshal(b []byte) error { 154 | return xxx_messageInfo_SimpleMessage.Unmarshal(m, b) 155 | } 156 | func (m *SimpleMessage) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { 157 | return xxx_messageInfo_SimpleMessage.Marshal(b, m, deterministic) 158 | } 159 | func (m *SimpleMessage) XXX_Merge(src proto.Message) { 160 | xxx_messageInfo_SimpleMessage.Merge(m, src) 161 | } 162 | func (m *SimpleMessage) XXX_Size() int { 163 | return xxx_messageInfo_SimpleMessage.Size(m) 164 | } 165 | func (m *SimpleMessage) XXX_DiscardUnknown() { 166 | xxx_messageInfo_SimpleMessage.DiscardUnknown(m) 167 | } 168 | 169 | var xxx_messageInfo_SimpleMessage proto.InternalMessageInfo 170 | 171 | func (m *SimpleMessage) GetStringValue() string { 172 | if m != nil { 173 | return m.StringValue 174 | } 175 | return "" 176 | } 177 | 178 | func (m *SimpleMessage) GetBoolValue() bool { 179 | if m != nil { 180 | return m.BoolValue 181 | } 182 | return false 183 | } 184 | 185 | type NotLoggingSimpleMessage struct { 186 | StringValue string `protobuf:"bytes,1,opt,name=string_value,json=stringValue,proto3" json:"string_value,omitempty"` 187 | BoolValue bool `protobuf:"varint,2,opt,name=bool_value,json=boolValue,proto3" json:"bool_value,omitempty"` 188 | XXX_NoUnkeyedLiteral struct{} `json:"-"` 189 | XXX_unrecognized []byte `json:"-"` 190 | XXX_sizecache int32 `json:"-"` 191 | } 192 | 193 | func (m *NotLoggingSimpleMessage) Reset() { *m = NotLoggingSimpleMessage{} } 194 | func (m *NotLoggingSimpleMessage) String() string { return proto.CompactTextString(m) } 195 | func (*NotLoggingSimpleMessage) ProtoMessage() {} 196 | func (*NotLoggingSimpleMessage) Descriptor() ([]byte, []int) { 197 | return fileDescriptor_722e198d308550d7, []int{1} 198 | } 199 | 200 | func (m *NotLoggingSimpleMessage) XXX_Unmarshal(b []byte) error { 201 | return xxx_messageInfo_NotLoggingSimpleMessage.Unmarshal(m, b) 202 | } 203 | func (m *NotLoggingSimpleMessage) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { 204 | return xxx_messageInfo_NotLoggingSimpleMessage.Marshal(b, m, deterministic) 205 | } 206 | func (m *NotLoggingSimpleMessage) XXX_Merge(src proto.Message) { 207 | xxx_messageInfo_NotLoggingSimpleMessage.Merge(m, src) 208 | } 209 | func (m *NotLoggingSimpleMessage) XXX_Size() int { 210 | return xxx_messageInfo_NotLoggingSimpleMessage.Size(m) 211 | } 212 | func (m *NotLoggingSimpleMessage) XXX_DiscardUnknown() { 213 | xxx_messageInfo_NotLoggingSimpleMessage.DiscardUnknown(m) 214 | } 215 | 216 | var xxx_messageInfo_NotLoggingSimpleMessage proto.InternalMessageInfo 217 | 218 | func (m *NotLoggingSimpleMessage) GetStringValue() string { 219 | if m != nil { 220 | return m.StringValue 221 | } 222 | return "" 223 | } 224 | 225 | func (m *NotLoggingSimpleMessage) GetBoolValue() bool { 226 | if m != nil { 227 | return m.BoolValue 228 | } 229 | return false 230 | } 231 | 232 | type NumberMessage struct { 233 | FloatValue float32 `protobuf:"fixed32,1,opt,name=float_value,json=floatValue,proto3" json:"float_value,omitempty"` 234 | DoubleValue float64 `protobuf:"fixed64,2,opt,name=double_value,json=doubleValue,proto3" json:"double_value,omitempty"` 235 | Int32Value int32 `protobuf:"varint,3,opt,name=int32_value,json=int32Value,proto3" json:"int32_value,omitempty"` 236 | Int64Value int64 `protobuf:"varint,4,opt,name=int64_value,json=int64Value,proto3" json:"int64_value,omitempty"` 237 | Uint32Value uint32 `protobuf:"varint,5,opt,name=uint32_value,json=uint32Value,proto3" json:"uint32_value,omitempty"` 238 | Uint64Value uint64 `protobuf:"varint,6,opt,name=uint64_value,json=uint64Value,proto3" json:"uint64_value,omitempty"` 239 | Sint32Value int32 `protobuf:"zigzag32,7,opt,name=sint32_value,json=sint32Value,proto3" json:"sint32_value,omitempty"` 240 | Sint64Value int64 `protobuf:"zigzag64,8,opt,name=sint64_value,json=sint64Value,proto3" json:"sint64_value,omitempty"` 241 | Fixed32Value uint32 `protobuf:"fixed32,9,opt,name=fixed32_value,json=fixed32Value,proto3" json:"fixed32_value,omitempty"` 242 | Fixed64Value uint64 `protobuf:"fixed64,10,opt,name=fixed64_value,json=fixed64Value,proto3" json:"fixed64_value,omitempty"` 243 | Sfixed32Value int32 `protobuf:"fixed32,11,opt,name=sfixed32_value,json=sfixed32Value,proto3" json:"sfixed32_value,omitempty"` 244 | Sfixed64Value int64 `protobuf:"fixed64,12,opt,name=sfixed64_value,json=sfixed64Value,proto3" json:"sfixed64_value,omitempty"` 245 | XXX_NoUnkeyedLiteral struct{} `json:"-"` 246 | XXX_unrecognized []byte `json:"-"` 247 | XXX_sizecache int32 `json:"-"` 248 | } 249 | 250 | func (m *NumberMessage) Reset() { *m = NumberMessage{} } 251 | func (m *NumberMessage) String() string { return proto.CompactTextString(m) } 252 | func (*NumberMessage) ProtoMessage() {} 253 | func (*NumberMessage) Descriptor() ([]byte, []int) { 254 | return fileDescriptor_722e198d308550d7, []int{2} 255 | } 256 | 257 | func (m *NumberMessage) XXX_Unmarshal(b []byte) error { 258 | return xxx_messageInfo_NumberMessage.Unmarshal(m, b) 259 | } 260 | func (m *NumberMessage) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { 261 | return xxx_messageInfo_NumberMessage.Marshal(b, m, deterministic) 262 | } 263 | func (m *NumberMessage) XXX_Merge(src proto.Message) { 264 | xxx_messageInfo_NumberMessage.Merge(m, src) 265 | } 266 | func (m *NumberMessage) XXX_Size() int { 267 | return xxx_messageInfo_NumberMessage.Size(m) 268 | } 269 | func (m *NumberMessage) XXX_DiscardUnknown() { 270 | xxx_messageInfo_NumberMessage.DiscardUnknown(m) 271 | } 272 | 273 | var xxx_messageInfo_NumberMessage proto.InternalMessageInfo 274 | 275 | func (m *NumberMessage) GetFloatValue() float32 { 276 | if m != nil { 277 | return m.FloatValue 278 | } 279 | return 0 280 | } 281 | 282 | func (m *NumberMessage) GetDoubleValue() float64 { 283 | if m != nil { 284 | return m.DoubleValue 285 | } 286 | return 0 287 | } 288 | 289 | func (m *NumberMessage) GetInt32Value() int32 { 290 | if m != nil { 291 | return m.Int32Value 292 | } 293 | return 0 294 | } 295 | 296 | func (m *NumberMessage) GetInt64Value() int64 { 297 | if m != nil { 298 | return m.Int64Value 299 | } 300 | return 0 301 | } 302 | 303 | func (m *NumberMessage) GetUint32Value() uint32 { 304 | if m != nil { 305 | return m.Uint32Value 306 | } 307 | return 0 308 | } 309 | 310 | func (m *NumberMessage) GetUint64Value() uint64 { 311 | if m != nil { 312 | return m.Uint64Value 313 | } 314 | return 0 315 | } 316 | 317 | func (m *NumberMessage) GetSint32Value() int32 { 318 | if m != nil { 319 | return m.Sint32Value 320 | } 321 | return 0 322 | } 323 | 324 | func (m *NumberMessage) GetSint64Value() int64 { 325 | if m != nil { 326 | return m.Sint64Value 327 | } 328 | return 0 329 | } 330 | 331 | func (m *NumberMessage) GetFixed32Value() uint32 { 332 | if m != nil { 333 | return m.Fixed32Value 334 | } 335 | return 0 336 | } 337 | 338 | func (m *NumberMessage) GetFixed64Value() uint64 { 339 | if m != nil { 340 | return m.Fixed64Value 341 | } 342 | return 0 343 | } 344 | 345 | func (m *NumberMessage) GetSfixed32Value() int32 { 346 | if m != nil { 347 | return m.Sfixed32Value 348 | } 349 | return 0 350 | } 351 | 352 | func (m *NumberMessage) GetSfixed64Value() int64 { 353 | if m != nil { 354 | return m.Sfixed64Value 355 | } 356 | return 0 357 | } 358 | 359 | type NotLoggingNumberMessage struct { 360 | FloatValue float32 `protobuf:"fixed32,1,opt,name=float_value,json=floatValue,proto3" json:"float_value,omitempty"` 361 | DoubleValue float64 `protobuf:"fixed64,2,opt,name=double_value,json=doubleValue,proto3" json:"double_value,omitempty"` 362 | Int32Value int32 `protobuf:"varint,3,opt,name=int32_value,json=int32Value,proto3" json:"int32_value,omitempty"` 363 | Int64Value int64 `protobuf:"varint,4,opt,name=int64_value,json=int64Value,proto3" json:"int64_value,omitempty"` 364 | Uint32Value uint32 `protobuf:"varint,5,opt,name=uint32_value,json=uint32Value,proto3" json:"uint32_value,omitempty"` 365 | Uint64Value uint64 `protobuf:"varint,6,opt,name=uint64_value,json=uint64Value,proto3" json:"uint64_value,omitempty"` 366 | Sint32Value int32 `protobuf:"zigzag32,7,opt,name=sint32_value,json=sint32Value,proto3" json:"sint32_value,omitempty"` 367 | Sint64Value int64 `protobuf:"zigzag64,8,opt,name=sint64_value,json=sint64Value,proto3" json:"sint64_value,omitempty"` 368 | Fixed32Value uint32 `protobuf:"fixed32,9,opt,name=fixed32_value,json=fixed32Value,proto3" json:"fixed32_value,omitempty"` 369 | Fixed64Value uint64 `protobuf:"fixed64,10,opt,name=fixed64_value,json=fixed64Value,proto3" json:"fixed64_value,omitempty"` 370 | Sfixed32Value int32 `protobuf:"fixed32,11,opt,name=sfixed32_value,json=sfixed32Value,proto3" json:"sfixed32_value,omitempty"` 371 | Sfixed64Value int64 `protobuf:"fixed64,12,opt,name=sfixed64_value,json=sfixed64Value,proto3" json:"sfixed64_value,omitempty"` 372 | XXX_NoUnkeyedLiteral struct{} `json:"-"` 373 | XXX_unrecognized []byte `json:"-"` 374 | XXX_sizecache int32 `json:"-"` 375 | } 376 | 377 | func (m *NotLoggingNumberMessage) Reset() { *m = NotLoggingNumberMessage{} } 378 | func (m *NotLoggingNumberMessage) String() string { return proto.CompactTextString(m) } 379 | func (*NotLoggingNumberMessage) ProtoMessage() {} 380 | func (*NotLoggingNumberMessage) Descriptor() ([]byte, []int) { 381 | return fileDescriptor_722e198d308550d7, []int{3} 382 | } 383 | 384 | func (m *NotLoggingNumberMessage) XXX_Unmarshal(b []byte) error { 385 | return xxx_messageInfo_NotLoggingNumberMessage.Unmarshal(m, b) 386 | } 387 | func (m *NotLoggingNumberMessage) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { 388 | return xxx_messageInfo_NotLoggingNumberMessage.Marshal(b, m, deterministic) 389 | } 390 | func (m *NotLoggingNumberMessage) XXX_Merge(src proto.Message) { 391 | xxx_messageInfo_NotLoggingNumberMessage.Merge(m, src) 392 | } 393 | func (m *NotLoggingNumberMessage) XXX_Size() int { 394 | return xxx_messageInfo_NotLoggingNumberMessage.Size(m) 395 | } 396 | func (m *NotLoggingNumberMessage) XXX_DiscardUnknown() { 397 | xxx_messageInfo_NotLoggingNumberMessage.DiscardUnknown(m) 398 | } 399 | 400 | var xxx_messageInfo_NotLoggingNumberMessage proto.InternalMessageInfo 401 | 402 | func (m *NotLoggingNumberMessage) GetFloatValue() float32 { 403 | if m != nil { 404 | return m.FloatValue 405 | } 406 | return 0 407 | } 408 | 409 | func (m *NotLoggingNumberMessage) GetDoubleValue() float64 { 410 | if m != nil { 411 | return m.DoubleValue 412 | } 413 | return 0 414 | } 415 | 416 | func (m *NotLoggingNumberMessage) GetInt32Value() int32 { 417 | if m != nil { 418 | return m.Int32Value 419 | } 420 | return 0 421 | } 422 | 423 | func (m *NotLoggingNumberMessage) GetInt64Value() int64 { 424 | if m != nil { 425 | return m.Int64Value 426 | } 427 | return 0 428 | } 429 | 430 | func (m *NotLoggingNumberMessage) GetUint32Value() uint32 { 431 | if m != nil { 432 | return m.Uint32Value 433 | } 434 | return 0 435 | } 436 | 437 | func (m *NotLoggingNumberMessage) GetUint64Value() uint64 { 438 | if m != nil { 439 | return m.Uint64Value 440 | } 441 | return 0 442 | } 443 | 444 | func (m *NotLoggingNumberMessage) GetSint32Value() int32 { 445 | if m != nil { 446 | return m.Sint32Value 447 | } 448 | return 0 449 | } 450 | 451 | func (m *NotLoggingNumberMessage) GetSint64Value() int64 { 452 | if m != nil { 453 | return m.Sint64Value 454 | } 455 | return 0 456 | } 457 | 458 | func (m *NotLoggingNumberMessage) GetFixed32Value() uint32 { 459 | if m != nil { 460 | return m.Fixed32Value 461 | } 462 | return 0 463 | } 464 | 465 | func (m *NotLoggingNumberMessage) GetFixed64Value() uint64 { 466 | if m != nil { 467 | return m.Fixed64Value 468 | } 469 | return 0 470 | } 471 | 472 | func (m *NotLoggingNumberMessage) GetSfixed32Value() int32 { 473 | if m != nil { 474 | return m.Sfixed32Value 475 | } 476 | return 0 477 | } 478 | 479 | func (m *NotLoggingNumberMessage) GetSfixed64Value() int64 { 480 | if m != nil { 481 | return m.Sfixed64Value 482 | } 483 | return 0 484 | } 485 | 486 | type RepeatedNumberMessage struct { 487 | FloatValues []float32 `protobuf:"fixed32,1,rep,packed,name=float_values,json=floatValues,proto3" json:"float_values,omitempty"` 488 | DoubleValues []float64 `protobuf:"fixed64,2,rep,packed,name=double_values,json=doubleValues,proto3" json:"double_values,omitempty"` 489 | Int32Values []int32 `protobuf:"varint,3,rep,packed,name=int32_values,json=int32Values,proto3" json:"int32_values,omitempty"` 490 | Int64Values []int64 `protobuf:"varint,4,rep,packed,name=int64_values,json=int64Values,proto3" json:"int64_values,omitempty"` 491 | Uint32Values []uint32 `protobuf:"varint,5,rep,packed,name=uint32_values,json=uint32Values,proto3" json:"uint32_values,omitempty"` 492 | Uint64Values []uint64 `protobuf:"varint,6,rep,packed,name=uint64_values,json=uint64Values,proto3" json:"uint64_values,omitempty"` 493 | Sint32Values []int32 `protobuf:"zigzag32,7,rep,packed,name=sint32_values,json=sint32Values,proto3" json:"sint32_values,omitempty"` 494 | Sint64Values []int64 `protobuf:"zigzag64,8,rep,packed,name=sint64_values,json=sint64Values,proto3" json:"sint64_values,omitempty"` 495 | Fixed32Values []uint32 `protobuf:"fixed32,9,rep,packed,name=fixed32_values,json=fixed32Values,proto3" json:"fixed32_values,omitempty"` 496 | Fixed64Values []uint64 `protobuf:"fixed64,10,rep,packed,name=fixed64_values,json=fixed64Values,proto3" json:"fixed64_values,omitempty"` 497 | Sfixed32Values []int32 `protobuf:"fixed32,11,rep,packed,name=sfixed32_values,json=sfixed32Values,proto3" json:"sfixed32_values,omitempty"` 498 | Sfixed64Values []int64 `protobuf:"fixed64,12,rep,packed,name=sfixed64_values,json=sfixed64Values,proto3" json:"sfixed64_values,omitempty"` 499 | XXX_NoUnkeyedLiteral struct{} `json:"-"` 500 | XXX_unrecognized []byte `json:"-"` 501 | XXX_sizecache int32 `json:"-"` 502 | } 503 | 504 | func (m *RepeatedNumberMessage) Reset() { *m = RepeatedNumberMessage{} } 505 | func (m *RepeatedNumberMessage) String() string { return proto.CompactTextString(m) } 506 | func (*RepeatedNumberMessage) ProtoMessage() {} 507 | func (*RepeatedNumberMessage) Descriptor() ([]byte, []int) { 508 | return fileDescriptor_722e198d308550d7, []int{4} 509 | } 510 | 511 | func (m *RepeatedNumberMessage) XXX_Unmarshal(b []byte) error { 512 | return xxx_messageInfo_RepeatedNumberMessage.Unmarshal(m, b) 513 | } 514 | func (m *RepeatedNumberMessage) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { 515 | return xxx_messageInfo_RepeatedNumberMessage.Marshal(b, m, deterministic) 516 | } 517 | func (m *RepeatedNumberMessage) XXX_Merge(src proto.Message) { 518 | xxx_messageInfo_RepeatedNumberMessage.Merge(m, src) 519 | } 520 | func (m *RepeatedNumberMessage) XXX_Size() int { 521 | return xxx_messageInfo_RepeatedNumberMessage.Size(m) 522 | } 523 | func (m *RepeatedNumberMessage) XXX_DiscardUnknown() { 524 | xxx_messageInfo_RepeatedNumberMessage.DiscardUnknown(m) 525 | } 526 | 527 | var xxx_messageInfo_RepeatedNumberMessage proto.InternalMessageInfo 528 | 529 | func (m *RepeatedNumberMessage) GetFloatValues() []float32 { 530 | if m != nil { 531 | return m.FloatValues 532 | } 533 | return nil 534 | } 535 | 536 | func (m *RepeatedNumberMessage) GetDoubleValues() []float64 { 537 | if m != nil { 538 | return m.DoubleValues 539 | } 540 | return nil 541 | } 542 | 543 | func (m *RepeatedNumberMessage) GetInt32Values() []int32 { 544 | if m != nil { 545 | return m.Int32Values 546 | } 547 | return nil 548 | } 549 | 550 | func (m *RepeatedNumberMessage) GetInt64Values() []int64 { 551 | if m != nil { 552 | return m.Int64Values 553 | } 554 | return nil 555 | } 556 | 557 | func (m *RepeatedNumberMessage) GetUint32Values() []uint32 { 558 | if m != nil { 559 | return m.Uint32Values 560 | } 561 | return nil 562 | } 563 | 564 | func (m *RepeatedNumberMessage) GetUint64Values() []uint64 { 565 | if m != nil { 566 | return m.Uint64Values 567 | } 568 | return nil 569 | } 570 | 571 | func (m *RepeatedNumberMessage) GetSint32Values() []int32 { 572 | if m != nil { 573 | return m.Sint32Values 574 | } 575 | return nil 576 | } 577 | 578 | func (m *RepeatedNumberMessage) GetSint64Values() []int64 { 579 | if m != nil { 580 | return m.Sint64Values 581 | } 582 | return nil 583 | } 584 | 585 | func (m *RepeatedNumberMessage) GetFixed32Values() []uint32 { 586 | if m != nil { 587 | return m.Fixed32Values 588 | } 589 | return nil 590 | } 591 | 592 | func (m *RepeatedNumberMessage) GetFixed64Values() []uint64 { 593 | if m != nil { 594 | return m.Fixed64Values 595 | } 596 | return nil 597 | } 598 | 599 | func (m *RepeatedNumberMessage) GetSfixed32Values() []int32 { 600 | if m != nil { 601 | return m.Sfixed32Values 602 | } 603 | return nil 604 | } 605 | 606 | func (m *RepeatedNumberMessage) GetSfixed64Values() []int64 { 607 | if m != nil { 608 | return m.Sfixed64Values 609 | } 610 | return nil 611 | } 612 | 613 | type NotLoggingRepeatedNumberMessage struct { 614 | FloatValues []float32 `protobuf:"fixed32,1,rep,packed,name=float_values,json=floatValues,proto3" json:"float_values,omitempty"` 615 | DoubleValues []float64 `protobuf:"fixed64,2,rep,packed,name=double_values,json=doubleValues,proto3" json:"double_values,omitempty"` 616 | Int32Values []int32 `protobuf:"varint,3,rep,packed,name=int32_values,json=int32Values,proto3" json:"int32_values,omitempty"` 617 | Int64Values []int64 `protobuf:"varint,4,rep,packed,name=int64_values,json=int64Values,proto3" json:"int64_values,omitempty"` 618 | Uint32Values []uint32 `protobuf:"varint,5,rep,packed,name=uint32_values,json=uint32Values,proto3" json:"uint32_values,omitempty"` 619 | Uint64Values []uint64 `protobuf:"varint,6,rep,packed,name=uint64_values,json=uint64Values,proto3" json:"uint64_values,omitempty"` 620 | Sint32Values []int32 `protobuf:"zigzag32,7,rep,packed,name=sint32_values,json=sint32Values,proto3" json:"sint32_values,omitempty"` 621 | Sint64Values []int64 `protobuf:"zigzag64,8,rep,packed,name=sint64_values,json=sint64Values,proto3" json:"sint64_values,omitempty"` 622 | Fixed32Values []uint32 `protobuf:"fixed32,9,rep,packed,name=fixed32_values,json=fixed32Values,proto3" json:"fixed32_values,omitempty"` 623 | Fixed64Values []uint64 `protobuf:"fixed64,10,rep,packed,name=fixed64_values,json=fixed64Values,proto3" json:"fixed64_values,omitempty"` 624 | Sfixed32Values []int32 `protobuf:"fixed32,11,rep,packed,name=sfixed32_values,json=sfixed32Values,proto3" json:"sfixed32_values,omitempty"` 625 | Sfixed64Values []int64 `protobuf:"fixed64,12,rep,packed,name=sfixed64_values,json=sfixed64Values,proto3" json:"sfixed64_values,omitempty"` 626 | XXX_NoUnkeyedLiteral struct{} `json:"-"` 627 | XXX_unrecognized []byte `json:"-"` 628 | XXX_sizecache int32 `json:"-"` 629 | } 630 | 631 | func (m *NotLoggingRepeatedNumberMessage) Reset() { *m = NotLoggingRepeatedNumberMessage{} } 632 | func (m *NotLoggingRepeatedNumberMessage) String() string { return proto.CompactTextString(m) } 633 | func (*NotLoggingRepeatedNumberMessage) ProtoMessage() {} 634 | func (*NotLoggingRepeatedNumberMessage) Descriptor() ([]byte, []int) { 635 | return fileDescriptor_722e198d308550d7, []int{5} 636 | } 637 | 638 | func (m *NotLoggingRepeatedNumberMessage) XXX_Unmarshal(b []byte) error { 639 | return xxx_messageInfo_NotLoggingRepeatedNumberMessage.Unmarshal(m, b) 640 | } 641 | func (m *NotLoggingRepeatedNumberMessage) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { 642 | return xxx_messageInfo_NotLoggingRepeatedNumberMessage.Marshal(b, m, deterministic) 643 | } 644 | func (m *NotLoggingRepeatedNumberMessage) XXX_Merge(src proto.Message) { 645 | xxx_messageInfo_NotLoggingRepeatedNumberMessage.Merge(m, src) 646 | } 647 | func (m *NotLoggingRepeatedNumberMessage) XXX_Size() int { 648 | return xxx_messageInfo_NotLoggingRepeatedNumberMessage.Size(m) 649 | } 650 | func (m *NotLoggingRepeatedNumberMessage) XXX_DiscardUnknown() { 651 | xxx_messageInfo_NotLoggingRepeatedNumberMessage.DiscardUnknown(m) 652 | } 653 | 654 | var xxx_messageInfo_NotLoggingRepeatedNumberMessage proto.InternalMessageInfo 655 | 656 | func (m *NotLoggingRepeatedNumberMessage) GetFloatValues() []float32 { 657 | if m != nil { 658 | return m.FloatValues 659 | } 660 | return nil 661 | } 662 | 663 | func (m *NotLoggingRepeatedNumberMessage) GetDoubleValues() []float64 { 664 | if m != nil { 665 | return m.DoubleValues 666 | } 667 | return nil 668 | } 669 | 670 | func (m *NotLoggingRepeatedNumberMessage) GetInt32Values() []int32 { 671 | if m != nil { 672 | return m.Int32Values 673 | } 674 | return nil 675 | } 676 | 677 | func (m *NotLoggingRepeatedNumberMessage) GetInt64Values() []int64 { 678 | if m != nil { 679 | return m.Int64Values 680 | } 681 | return nil 682 | } 683 | 684 | func (m *NotLoggingRepeatedNumberMessage) GetUint32Values() []uint32 { 685 | if m != nil { 686 | return m.Uint32Values 687 | } 688 | return nil 689 | } 690 | 691 | func (m *NotLoggingRepeatedNumberMessage) GetUint64Values() []uint64 { 692 | if m != nil { 693 | return m.Uint64Values 694 | } 695 | return nil 696 | } 697 | 698 | func (m *NotLoggingRepeatedNumberMessage) GetSint32Values() []int32 { 699 | if m != nil { 700 | return m.Sint32Values 701 | } 702 | return nil 703 | } 704 | 705 | func (m *NotLoggingRepeatedNumberMessage) GetSint64Values() []int64 { 706 | if m != nil { 707 | return m.Sint64Values 708 | } 709 | return nil 710 | } 711 | 712 | func (m *NotLoggingRepeatedNumberMessage) GetFixed32Values() []uint32 { 713 | if m != nil { 714 | return m.Fixed32Values 715 | } 716 | return nil 717 | } 718 | 719 | func (m *NotLoggingRepeatedNumberMessage) GetFixed64Values() []uint64 { 720 | if m != nil { 721 | return m.Fixed64Values 722 | } 723 | return nil 724 | } 725 | 726 | func (m *NotLoggingRepeatedNumberMessage) GetSfixed32Values() []int32 { 727 | if m != nil { 728 | return m.Sfixed32Values 729 | } 730 | return nil 731 | } 732 | 733 | func (m *NotLoggingRepeatedNumberMessage) GetSfixed64Values() []int64 { 734 | if m != nil { 735 | return m.Sfixed64Values 736 | } 737 | return nil 738 | } 739 | 740 | type NestedMessage struct { 741 | NestedValue *NestedMessage_Nested `protobuf:"bytes,1,opt,name=nested_value,json=nestedValue,proto3" json:"nested_value,omitempty"` 742 | RepeatedNestedValues []*NestedMessage_Nested `protobuf:"bytes,2,rep,name=repeated_nested_values,json=repeatedNestedValues,proto3" json:"repeated_nested_values,omitempty"` 743 | XXX_NoUnkeyedLiteral struct{} `json:"-"` 744 | XXX_unrecognized []byte `json:"-"` 745 | XXX_sizecache int32 `json:"-"` 746 | } 747 | 748 | func (m *NestedMessage) Reset() { *m = NestedMessage{} } 749 | func (m *NestedMessage) String() string { return proto.CompactTextString(m) } 750 | func (*NestedMessage) ProtoMessage() {} 751 | func (*NestedMessage) Descriptor() ([]byte, []int) { 752 | return fileDescriptor_722e198d308550d7, []int{6} 753 | } 754 | 755 | func (m *NestedMessage) XXX_Unmarshal(b []byte) error { 756 | return xxx_messageInfo_NestedMessage.Unmarshal(m, b) 757 | } 758 | func (m *NestedMessage) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { 759 | return xxx_messageInfo_NestedMessage.Marshal(b, m, deterministic) 760 | } 761 | func (m *NestedMessage) XXX_Merge(src proto.Message) { 762 | xxx_messageInfo_NestedMessage.Merge(m, src) 763 | } 764 | func (m *NestedMessage) XXX_Size() int { 765 | return xxx_messageInfo_NestedMessage.Size(m) 766 | } 767 | func (m *NestedMessage) XXX_DiscardUnknown() { 768 | xxx_messageInfo_NestedMessage.DiscardUnknown(m) 769 | } 770 | 771 | var xxx_messageInfo_NestedMessage proto.InternalMessageInfo 772 | 773 | func (m *NestedMessage) GetNestedValue() *NestedMessage_Nested { 774 | if m != nil { 775 | return m.NestedValue 776 | } 777 | return nil 778 | } 779 | 780 | func (m *NestedMessage) GetRepeatedNestedValues() []*NestedMessage_Nested { 781 | if m != nil { 782 | return m.RepeatedNestedValues 783 | } 784 | return nil 785 | } 786 | 787 | type NestedMessage_Nested struct { 788 | Int32Value int32 `protobuf:"varint,1,opt,name=int32_value,json=int32Value,proto3" json:"int32_value,omitempty"` 789 | StringValue string `protobuf:"bytes,2,opt,name=string_value,json=stringValue,proto3" json:"string_value,omitempty"` 790 | XXX_NoUnkeyedLiteral struct{} `json:"-"` 791 | XXX_unrecognized []byte `json:"-"` 792 | XXX_sizecache int32 `json:"-"` 793 | } 794 | 795 | func (m *NestedMessage_Nested) Reset() { *m = NestedMessage_Nested{} } 796 | func (m *NestedMessage_Nested) String() string { return proto.CompactTextString(m) } 797 | func (*NestedMessage_Nested) ProtoMessage() {} 798 | func (*NestedMessage_Nested) Descriptor() ([]byte, []int) { 799 | return fileDescriptor_722e198d308550d7, []int{6, 0} 800 | } 801 | 802 | func (m *NestedMessage_Nested) XXX_Unmarshal(b []byte) error { 803 | return xxx_messageInfo_NestedMessage_Nested.Unmarshal(m, b) 804 | } 805 | func (m *NestedMessage_Nested) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { 806 | return xxx_messageInfo_NestedMessage_Nested.Marshal(b, m, deterministic) 807 | } 808 | func (m *NestedMessage_Nested) XXX_Merge(src proto.Message) { 809 | xxx_messageInfo_NestedMessage_Nested.Merge(m, src) 810 | } 811 | func (m *NestedMessage_Nested) XXX_Size() int { 812 | return xxx_messageInfo_NestedMessage_Nested.Size(m) 813 | } 814 | func (m *NestedMessage_Nested) XXX_DiscardUnknown() { 815 | xxx_messageInfo_NestedMessage_Nested.DiscardUnknown(m) 816 | } 817 | 818 | var xxx_messageInfo_NestedMessage_Nested proto.InternalMessageInfo 819 | 820 | func (m *NestedMessage_Nested) GetInt32Value() int32 { 821 | if m != nil { 822 | return m.Int32Value 823 | } 824 | return 0 825 | } 826 | 827 | func (m *NestedMessage_Nested) GetStringValue() string { 828 | if m != nil { 829 | return m.StringValue 830 | } 831 | return "" 832 | } 833 | 834 | type NotLoggingNestedMessage struct { 835 | NestedValue *NotLoggingNestedMessage_Nested `protobuf:"bytes,1,opt,name=nested_value,json=nestedValue,proto3" json:"nested_value,omitempty"` 836 | RepeatedNestedValues []*NotLoggingNestedMessage_Nested `protobuf:"bytes,2,rep,name=repeated_nested_values,json=repeatedNestedValues,proto3" json:"repeated_nested_values,omitempty"` 837 | XXX_NoUnkeyedLiteral struct{} `json:"-"` 838 | XXX_unrecognized []byte `json:"-"` 839 | XXX_sizecache int32 `json:"-"` 840 | } 841 | 842 | func (m *NotLoggingNestedMessage) Reset() { *m = NotLoggingNestedMessage{} } 843 | func (m *NotLoggingNestedMessage) String() string { return proto.CompactTextString(m) } 844 | func (*NotLoggingNestedMessage) ProtoMessage() {} 845 | func (*NotLoggingNestedMessage) Descriptor() ([]byte, []int) { 846 | return fileDescriptor_722e198d308550d7, []int{7} 847 | } 848 | 849 | func (m *NotLoggingNestedMessage) XXX_Unmarshal(b []byte) error { 850 | return xxx_messageInfo_NotLoggingNestedMessage.Unmarshal(m, b) 851 | } 852 | func (m *NotLoggingNestedMessage) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { 853 | return xxx_messageInfo_NotLoggingNestedMessage.Marshal(b, m, deterministic) 854 | } 855 | func (m *NotLoggingNestedMessage) XXX_Merge(src proto.Message) { 856 | xxx_messageInfo_NotLoggingNestedMessage.Merge(m, src) 857 | } 858 | func (m *NotLoggingNestedMessage) XXX_Size() int { 859 | return xxx_messageInfo_NotLoggingNestedMessage.Size(m) 860 | } 861 | func (m *NotLoggingNestedMessage) XXX_DiscardUnknown() { 862 | xxx_messageInfo_NotLoggingNestedMessage.DiscardUnknown(m) 863 | } 864 | 865 | var xxx_messageInfo_NotLoggingNestedMessage proto.InternalMessageInfo 866 | 867 | func (m *NotLoggingNestedMessage) GetNestedValue() *NotLoggingNestedMessage_Nested { 868 | if m != nil { 869 | return m.NestedValue 870 | } 871 | return nil 872 | } 873 | 874 | func (m *NotLoggingNestedMessage) GetRepeatedNestedValues() []*NotLoggingNestedMessage_Nested { 875 | if m != nil { 876 | return m.RepeatedNestedValues 877 | } 878 | return nil 879 | } 880 | 881 | type NotLoggingNestedMessage_Nested struct { 882 | Int32Value int32 `protobuf:"varint,1,opt,name=int32_value,json=int32Value,proto3" json:"int32_value,omitempty"` 883 | StringValue string `protobuf:"bytes,2,opt,name=string_value,json=stringValue,proto3" json:"string_value,omitempty"` 884 | XXX_NoUnkeyedLiteral struct{} `json:"-"` 885 | XXX_unrecognized []byte `json:"-"` 886 | XXX_sizecache int32 `json:"-"` 887 | } 888 | 889 | func (m *NotLoggingNestedMessage_Nested) Reset() { *m = NotLoggingNestedMessage_Nested{} } 890 | func (m *NotLoggingNestedMessage_Nested) String() string { return proto.CompactTextString(m) } 891 | func (*NotLoggingNestedMessage_Nested) ProtoMessage() {} 892 | func (*NotLoggingNestedMessage_Nested) Descriptor() ([]byte, []int) { 893 | return fileDescriptor_722e198d308550d7, []int{7, 0} 894 | } 895 | 896 | func (m *NotLoggingNestedMessage_Nested) XXX_Unmarshal(b []byte) error { 897 | return xxx_messageInfo_NotLoggingNestedMessage_Nested.Unmarshal(m, b) 898 | } 899 | func (m *NotLoggingNestedMessage_Nested) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { 900 | return xxx_messageInfo_NotLoggingNestedMessage_Nested.Marshal(b, m, deterministic) 901 | } 902 | func (m *NotLoggingNestedMessage_Nested) XXX_Merge(src proto.Message) { 903 | xxx_messageInfo_NotLoggingNestedMessage_Nested.Merge(m, src) 904 | } 905 | func (m *NotLoggingNestedMessage_Nested) XXX_Size() int { 906 | return xxx_messageInfo_NotLoggingNestedMessage_Nested.Size(m) 907 | } 908 | func (m *NotLoggingNestedMessage_Nested) XXX_DiscardUnknown() { 909 | xxx_messageInfo_NotLoggingNestedMessage_Nested.DiscardUnknown(m) 910 | } 911 | 912 | var xxx_messageInfo_NotLoggingNestedMessage_Nested proto.InternalMessageInfo 913 | 914 | func (m *NotLoggingNestedMessage_Nested) GetInt32Value() int32 { 915 | if m != nil { 916 | return m.Int32Value 917 | } 918 | return 0 919 | } 920 | 921 | func (m *NotLoggingNestedMessage_Nested) GetStringValue() string { 922 | if m != nil { 923 | return m.StringValue 924 | } 925 | return "" 926 | } 927 | 928 | type EnumMessage struct { 929 | NumericEnumValue NumericEnum `protobuf:"varint,1,opt,name=numeric_enum_value,json=numericEnumValue,proto3,enum=kazegusuri.zapmarshaler.example.NumericEnum" json:"numeric_enum_value,omitempty"` 930 | RepeatedNumericEnumValues []NumericEnum `protobuf:"varint,2,rep,packed,name=repeated_numeric_enum_values,json=repeatedNumericEnumValues,proto3,enum=kazegusuri.zapmarshaler.example.NumericEnum" json:"repeated_numeric_enum_values,omitempty"` 931 | AliasedEnumValue AliasedEnum `protobuf:"varint,3,opt,name=aliased_enum_value,json=aliasedEnumValue,proto3,enum=kazegusuri.zapmarshaler.example.AliasedEnum" json:"aliased_enum_value,omitempty"` 932 | NestedEnumValue EnumMessage_Nested `protobuf:"varint,4,opt,name=nested_enum_value,json=nestedEnumValue,proto3,enum=kazegusuri.zapmarshaler.example.EnumMessage_Nested" json:"nested_enum_value,omitempty"` 933 | RepeatedNestedEnumValues []EnumMessage_Nested `protobuf:"varint,5,rep,packed,name=repeated_nested_enum_values,json=repeatedNestedEnumValues,proto3,enum=kazegusuri.zapmarshaler.example.EnumMessage_Nested" json:"repeated_nested_enum_values,omitempty"` 934 | XXX_NoUnkeyedLiteral struct{} `json:"-"` 935 | XXX_unrecognized []byte `json:"-"` 936 | XXX_sizecache int32 `json:"-"` 937 | } 938 | 939 | func (m *EnumMessage) Reset() { *m = EnumMessage{} } 940 | func (m *EnumMessage) String() string { return proto.CompactTextString(m) } 941 | func (*EnumMessage) ProtoMessage() {} 942 | func (*EnumMessage) Descriptor() ([]byte, []int) { 943 | return fileDescriptor_722e198d308550d7, []int{8} 944 | } 945 | 946 | func (m *EnumMessage) XXX_Unmarshal(b []byte) error { 947 | return xxx_messageInfo_EnumMessage.Unmarshal(m, b) 948 | } 949 | func (m *EnumMessage) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { 950 | return xxx_messageInfo_EnumMessage.Marshal(b, m, deterministic) 951 | } 952 | func (m *EnumMessage) XXX_Merge(src proto.Message) { 953 | xxx_messageInfo_EnumMessage.Merge(m, src) 954 | } 955 | func (m *EnumMessage) XXX_Size() int { 956 | return xxx_messageInfo_EnumMessage.Size(m) 957 | } 958 | func (m *EnumMessage) XXX_DiscardUnknown() { 959 | xxx_messageInfo_EnumMessage.DiscardUnknown(m) 960 | } 961 | 962 | var xxx_messageInfo_EnumMessage proto.InternalMessageInfo 963 | 964 | func (m *EnumMessage) GetNumericEnumValue() NumericEnum { 965 | if m != nil { 966 | return m.NumericEnumValue 967 | } 968 | return NumericEnum_ZERO 969 | } 970 | 971 | func (m *EnumMessage) GetRepeatedNumericEnumValues() []NumericEnum { 972 | if m != nil { 973 | return m.RepeatedNumericEnumValues 974 | } 975 | return nil 976 | } 977 | 978 | func (m *EnumMessage) GetAliasedEnumValue() AliasedEnum { 979 | if m != nil { 980 | return m.AliasedEnumValue 981 | } 982 | return AliasedEnum_UNKNOWN 983 | } 984 | 985 | func (m *EnumMessage) GetNestedEnumValue() EnumMessage_Nested { 986 | if m != nil { 987 | return m.NestedEnumValue 988 | } 989 | return EnumMessage_UNKNOWN 990 | } 991 | 992 | func (m *EnumMessage) GetRepeatedNestedEnumValues() []EnumMessage_Nested { 993 | if m != nil { 994 | return m.RepeatedNestedEnumValues 995 | } 996 | return nil 997 | } 998 | 999 | type NotLoggingEnumMessage struct { 1000 | NumericEnumValue NumericEnum `protobuf:"varint,1,opt,name=numeric_enum_value,json=numericEnumValue,proto3,enum=kazegusuri.zapmarshaler.example.NumericEnum" json:"numeric_enum_value,omitempty"` 1001 | RepeatedNumericEnumValues []NumericEnum `protobuf:"varint,2,rep,packed,name=repeated_numeric_enum_values,json=repeatedNumericEnumValues,proto3,enum=kazegusuri.zapmarshaler.example.NumericEnum" json:"repeated_numeric_enum_values,omitempty"` 1002 | AliasedEnumValue AliasedEnum `protobuf:"varint,3,opt,name=aliased_enum_value,json=aliasedEnumValue,proto3,enum=kazegusuri.zapmarshaler.example.AliasedEnum" json:"aliased_enum_value,omitempty"` 1003 | NestedEnumValue NotLoggingEnumMessage_Nested `protobuf:"varint,4,opt,name=nested_enum_value,json=nestedEnumValue,proto3,enum=kazegusuri.zapmarshaler.example.NotLoggingEnumMessage_Nested" json:"nested_enum_value,omitempty"` 1004 | RepeatedNestedEnumValues []NotLoggingEnumMessage_Nested `protobuf:"varint,5,rep,packed,name=repeated_nested_enum_values,json=repeatedNestedEnumValues,proto3,enum=kazegusuri.zapmarshaler.example.NotLoggingEnumMessage_Nested" json:"repeated_nested_enum_values,omitempty"` 1005 | XXX_NoUnkeyedLiteral struct{} `json:"-"` 1006 | XXX_unrecognized []byte `json:"-"` 1007 | XXX_sizecache int32 `json:"-"` 1008 | } 1009 | 1010 | func (m *NotLoggingEnumMessage) Reset() { *m = NotLoggingEnumMessage{} } 1011 | func (m *NotLoggingEnumMessage) String() string { return proto.CompactTextString(m) } 1012 | func (*NotLoggingEnumMessage) ProtoMessage() {} 1013 | func (*NotLoggingEnumMessage) Descriptor() ([]byte, []int) { 1014 | return fileDescriptor_722e198d308550d7, []int{9} 1015 | } 1016 | 1017 | func (m *NotLoggingEnumMessage) XXX_Unmarshal(b []byte) error { 1018 | return xxx_messageInfo_NotLoggingEnumMessage.Unmarshal(m, b) 1019 | } 1020 | func (m *NotLoggingEnumMessage) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { 1021 | return xxx_messageInfo_NotLoggingEnumMessage.Marshal(b, m, deterministic) 1022 | } 1023 | func (m *NotLoggingEnumMessage) XXX_Merge(src proto.Message) { 1024 | xxx_messageInfo_NotLoggingEnumMessage.Merge(m, src) 1025 | } 1026 | func (m *NotLoggingEnumMessage) XXX_Size() int { 1027 | return xxx_messageInfo_NotLoggingEnumMessage.Size(m) 1028 | } 1029 | func (m *NotLoggingEnumMessage) XXX_DiscardUnknown() { 1030 | xxx_messageInfo_NotLoggingEnumMessage.DiscardUnknown(m) 1031 | } 1032 | 1033 | var xxx_messageInfo_NotLoggingEnumMessage proto.InternalMessageInfo 1034 | 1035 | func (m *NotLoggingEnumMessage) GetNumericEnumValue() NumericEnum { 1036 | if m != nil { 1037 | return m.NumericEnumValue 1038 | } 1039 | return NumericEnum_ZERO 1040 | } 1041 | 1042 | func (m *NotLoggingEnumMessage) GetRepeatedNumericEnumValues() []NumericEnum { 1043 | if m != nil { 1044 | return m.RepeatedNumericEnumValues 1045 | } 1046 | return nil 1047 | } 1048 | 1049 | func (m *NotLoggingEnumMessage) GetAliasedEnumValue() AliasedEnum { 1050 | if m != nil { 1051 | return m.AliasedEnumValue 1052 | } 1053 | return AliasedEnum_UNKNOWN 1054 | } 1055 | 1056 | func (m *NotLoggingEnumMessage) GetNestedEnumValue() NotLoggingEnumMessage_Nested { 1057 | if m != nil { 1058 | return m.NestedEnumValue 1059 | } 1060 | return NotLoggingEnumMessage_UNKNOWN 1061 | } 1062 | 1063 | func (m *NotLoggingEnumMessage) GetRepeatedNestedEnumValues() []NotLoggingEnumMessage_Nested { 1064 | if m != nil { 1065 | return m.RepeatedNestedEnumValues 1066 | } 1067 | return nil 1068 | } 1069 | 1070 | type Oneof struct { 1071 | // Types that are valid to be assigned to OneofValue: 1072 | // *Oneof_Int32Value 1073 | // *Oneof_StringValue 1074 | OneofValue isOneof_OneofValue `protobuf_oneof:"oneof_value"` 1075 | XXX_NoUnkeyedLiteral struct{} `json:"-"` 1076 | XXX_unrecognized []byte `json:"-"` 1077 | XXX_sizecache int32 `json:"-"` 1078 | } 1079 | 1080 | func (m *Oneof) Reset() { *m = Oneof{} } 1081 | func (m *Oneof) String() string { return proto.CompactTextString(m) } 1082 | func (*Oneof) ProtoMessage() {} 1083 | func (*Oneof) Descriptor() ([]byte, []int) { 1084 | return fileDescriptor_722e198d308550d7, []int{10} 1085 | } 1086 | 1087 | func (m *Oneof) XXX_Unmarshal(b []byte) error { 1088 | return xxx_messageInfo_Oneof.Unmarshal(m, b) 1089 | } 1090 | func (m *Oneof) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { 1091 | return xxx_messageInfo_Oneof.Marshal(b, m, deterministic) 1092 | } 1093 | func (m *Oneof) XXX_Merge(src proto.Message) { 1094 | xxx_messageInfo_Oneof.Merge(m, src) 1095 | } 1096 | func (m *Oneof) XXX_Size() int { 1097 | return xxx_messageInfo_Oneof.Size(m) 1098 | } 1099 | func (m *Oneof) XXX_DiscardUnknown() { 1100 | xxx_messageInfo_Oneof.DiscardUnknown(m) 1101 | } 1102 | 1103 | var xxx_messageInfo_Oneof proto.InternalMessageInfo 1104 | 1105 | type isOneof_OneofValue interface { 1106 | isOneof_OneofValue() 1107 | } 1108 | 1109 | type Oneof_Int32Value struct { 1110 | Int32Value int32 `protobuf:"varint,1,opt,name=int32_value,json=int32Value,proto3,oneof"` 1111 | } 1112 | 1113 | type Oneof_StringValue struct { 1114 | StringValue string `protobuf:"bytes,2,opt,name=string_value,json=stringValue,proto3,oneof"` 1115 | } 1116 | 1117 | func (*Oneof_Int32Value) isOneof_OneofValue() {} 1118 | 1119 | func (*Oneof_StringValue) isOneof_OneofValue() {} 1120 | 1121 | func (m *Oneof) GetOneofValue() isOneof_OneofValue { 1122 | if m != nil { 1123 | return m.OneofValue 1124 | } 1125 | return nil 1126 | } 1127 | 1128 | func (m *Oneof) GetInt32Value() int32 { 1129 | if x, ok := m.GetOneofValue().(*Oneof_Int32Value); ok { 1130 | return x.Int32Value 1131 | } 1132 | return 0 1133 | } 1134 | 1135 | func (m *Oneof) GetStringValue() string { 1136 | if x, ok := m.GetOneofValue().(*Oneof_StringValue); ok { 1137 | return x.StringValue 1138 | } 1139 | return "" 1140 | } 1141 | 1142 | // XXX_OneofWrappers is for the internal use of the proto package. 1143 | func (*Oneof) XXX_OneofWrappers() []interface{} { 1144 | return []interface{}{ 1145 | (*Oneof_Int32Value)(nil), 1146 | (*Oneof_StringValue)(nil), 1147 | } 1148 | } 1149 | 1150 | type OneofMessage struct { 1151 | // Types that are valid to be assigned to OneofValue: 1152 | // *OneofMessage_Int32Value 1153 | // *OneofMessage_StringValue 1154 | OneofValue isOneofMessage_OneofValue `protobuf_oneof:"oneof_value"` 1155 | RepeatedOneofValues []*Oneof `protobuf:"bytes,3,rep,name=repeated_oneof_values,json=repeatedOneofValues,proto3" json:"repeated_oneof_values,omitempty"` 1156 | XXX_NoUnkeyedLiteral struct{} `json:"-"` 1157 | XXX_unrecognized []byte `json:"-"` 1158 | XXX_sizecache int32 `json:"-"` 1159 | } 1160 | 1161 | func (m *OneofMessage) Reset() { *m = OneofMessage{} } 1162 | func (m *OneofMessage) String() string { return proto.CompactTextString(m) } 1163 | func (*OneofMessage) ProtoMessage() {} 1164 | func (*OneofMessage) Descriptor() ([]byte, []int) { 1165 | return fileDescriptor_722e198d308550d7, []int{11} 1166 | } 1167 | 1168 | func (m *OneofMessage) XXX_Unmarshal(b []byte) error { 1169 | return xxx_messageInfo_OneofMessage.Unmarshal(m, b) 1170 | } 1171 | func (m *OneofMessage) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { 1172 | return xxx_messageInfo_OneofMessage.Marshal(b, m, deterministic) 1173 | } 1174 | func (m *OneofMessage) XXX_Merge(src proto.Message) { 1175 | xxx_messageInfo_OneofMessage.Merge(m, src) 1176 | } 1177 | func (m *OneofMessage) XXX_Size() int { 1178 | return xxx_messageInfo_OneofMessage.Size(m) 1179 | } 1180 | func (m *OneofMessage) XXX_DiscardUnknown() { 1181 | xxx_messageInfo_OneofMessage.DiscardUnknown(m) 1182 | } 1183 | 1184 | var xxx_messageInfo_OneofMessage proto.InternalMessageInfo 1185 | 1186 | type isOneofMessage_OneofValue interface { 1187 | isOneofMessage_OneofValue() 1188 | } 1189 | 1190 | type OneofMessage_Int32Value struct { 1191 | Int32Value int32 `protobuf:"varint,1,opt,name=int32_value,json=int32Value,proto3,oneof"` 1192 | } 1193 | 1194 | type OneofMessage_StringValue struct { 1195 | StringValue string `protobuf:"bytes,2,opt,name=string_value,json=stringValue,proto3,oneof"` 1196 | } 1197 | 1198 | func (*OneofMessage_Int32Value) isOneofMessage_OneofValue() {} 1199 | 1200 | func (*OneofMessage_StringValue) isOneofMessage_OneofValue() {} 1201 | 1202 | func (m *OneofMessage) GetOneofValue() isOneofMessage_OneofValue { 1203 | if m != nil { 1204 | return m.OneofValue 1205 | } 1206 | return nil 1207 | } 1208 | 1209 | func (m *OneofMessage) GetInt32Value() int32 { 1210 | if x, ok := m.GetOneofValue().(*OneofMessage_Int32Value); ok { 1211 | return x.Int32Value 1212 | } 1213 | return 0 1214 | } 1215 | 1216 | func (m *OneofMessage) GetStringValue() string { 1217 | if x, ok := m.GetOneofValue().(*OneofMessage_StringValue); ok { 1218 | return x.StringValue 1219 | } 1220 | return "" 1221 | } 1222 | 1223 | func (m *OneofMessage) GetRepeatedOneofValues() []*Oneof { 1224 | if m != nil { 1225 | return m.RepeatedOneofValues 1226 | } 1227 | return nil 1228 | } 1229 | 1230 | // XXX_OneofWrappers is for the internal use of the proto package. 1231 | func (*OneofMessage) XXX_OneofWrappers() []interface{} { 1232 | return []interface{}{ 1233 | (*OneofMessage_Int32Value)(nil), 1234 | (*OneofMessage_StringValue)(nil), 1235 | } 1236 | } 1237 | 1238 | type NotLoggingOneofMessage struct { 1239 | // Types that are valid to be assigned to OneofValue: 1240 | // *NotLoggingOneofMessage_Int32Value 1241 | // *NotLoggingOneofMessage_StringValue 1242 | OneofValue isNotLoggingOneofMessage_OneofValue `protobuf_oneof:"oneof_value"` 1243 | RepeatedOneofValues []*Oneof `protobuf:"bytes,3,rep,name=repeated_oneof_values,json=repeatedOneofValues,proto3" json:"repeated_oneof_values,omitempty"` 1244 | XXX_NoUnkeyedLiteral struct{} `json:"-"` 1245 | XXX_unrecognized []byte `json:"-"` 1246 | XXX_sizecache int32 `json:"-"` 1247 | } 1248 | 1249 | func (m *NotLoggingOneofMessage) Reset() { *m = NotLoggingOneofMessage{} } 1250 | func (m *NotLoggingOneofMessage) String() string { return proto.CompactTextString(m) } 1251 | func (*NotLoggingOneofMessage) ProtoMessage() {} 1252 | func (*NotLoggingOneofMessage) Descriptor() ([]byte, []int) { 1253 | return fileDescriptor_722e198d308550d7, []int{12} 1254 | } 1255 | 1256 | func (m *NotLoggingOneofMessage) XXX_Unmarshal(b []byte) error { 1257 | return xxx_messageInfo_NotLoggingOneofMessage.Unmarshal(m, b) 1258 | } 1259 | func (m *NotLoggingOneofMessage) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { 1260 | return xxx_messageInfo_NotLoggingOneofMessage.Marshal(b, m, deterministic) 1261 | } 1262 | func (m *NotLoggingOneofMessage) XXX_Merge(src proto.Message) { 1263 | xxx_messageInfo_NotLoggingOneofMessage.Merge(m, src) 1264 | } 1265 | func (m *NotLoggingOneofMessage) XXX_Size() int { 1266 | return xxx_messageInfo_NotLoggingOneofMessage.Size(m) 1267 | } 1268 | func (m *NotLoggingOneofMessage) XXX_DiscardUnknown() { 1269 | xxx_messageInfo_NotLoggingOneofMessage.DiscardUnknown(m) 1270 | } 1271 | 1272 | var xxx_messageInfo_NotLoggingOneofMessage proto.InternalMessageInfo 1273 | 1274 | type isNotLoggingOneofMessage_OneofValue interface { 1275 | isNotLoggingOneofMessage_OneofValue() 1276 | } 1277 | 1278 | type NotLoggingOneofMessage_Int32Value struct { 1279 | Int32Value int32 `protobuf:"varint,1,opt,name=int32_value,json=int32Value,proto3,oneof"` 1280 | } 1281 | 1282 | type NotLoggingOneofMessage_StringValue struct { 1283 | StringValue string `protobuf:"bytes,2,opt,name=string_value,json=stringValue,proto3,oneof"` 1284 | } 1285 | 1286 | func (*NotLoggingOneofMessage_Int32Value) isNotLoggingOneofMessage_OneofValue() {} 1287 | 1288 | func (*NotLoggingOneofMessage_StringValue) isNotLoggingOneofMessage_OneofValue() {} 1289 | 1290 | func (m *NotLoggingOneofMessage) GetOneofValue() isNotLoggingOneofMessage_OneofValue { 1291 | if m != nil { 1292 | return m.OneofValue 1293 | } 1294 | return nil 1295 | } 1296 | 1297 | func (m *NotLoggingOneofMessage) GetInt32Value() int32 { 1298 | if x, ok := m.GetOneofValue().(*NotLoggingOneofMessage_Int32Value); ok { 1299 | return x.Int32Value 1300 | } 1301 | return 0 1302 | } 1303 | 1304 | func (m *NotLoggingOneofMessage) GetStringValue() string { 1305 | if x, ok := m.GetOneofValue().(*NotLoggingOneofMessage_StringValue); ok { 1306 | return x.StringValue 1307 | } 1308 | return "" 1309 | } 1310 | 1311 | func (m *NotLoggingOneofMessage) GetRepeatedOneofValues() []*Oneof { 1312 | if m != nil { 1313 | return m.RepeatedOneofValues 1314 | } 1315 | return nil 1316 | } 1317 | 1318 | // XXX_OneofWrappers is for the internal use of the proto package. 1319 | func (*NotLoggingOneofMessage) XXX_OneofWrappers() []interface{} { 1320 | return []interface{}{ 1321 | (*NotLoggingOneofMessage_Int32Value)(nil), 1322 | (*NotLoggingOneofMessage_StringValue)(nil), 1323 | } 1324 | } 1325 | 1326 | type MapMessage struct { 1327 | MappedValue map[int32]string `protobuf:"bytes,1,rep,name=mapped_value,json=mappedValue,proto3" json:"mapped_value,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` 1328 | MappedEnumValue map[string]NumericEnum `protobuf:"bytes,2,rep,name=mapped_enum_value,json=mappedEnumValue,proto3" json:"mapped_enum_value,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3,enum=kazegusuri.zapmarshaler.example.NumericEnum"` 1329 | MappedNestedValue map[string]*NestedMessage `protobuf:"bytes,3,rep,name=mapped_nested_value,json=mappedNestedValue,proto3" json:"mapped_nested_value,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` 1330 | XXX_NoUnkeyedLiteral struct{} `json:"-"` 1331 | XXX_unrecognized []byte `json:"-"` 1332 | XXX_sizecache int32 `json:"-"` 1333 | } 1334 | 1335 | func (m *MapMessage) Reset() { *m = MapMessage{} } 1336 | func (m *MapMessage) String() string { return proto.CompactTextString(m) } 1337 | func (*MapMessage) ProtoMessage() {} 1338 | func (*MapMessage) Descriptor() ([]byte, []int) { 1339 | return fileDescriptor_722e198d308550d7, []int{13} 1340 | } 1341 | 1342 | func (m *MapMessage) XXX_Unmarshal(b []byte) error { 1343 | return xxx_messageInfo_MapMessage.Unmarshal(m, b) 1344 | } 1345 | func (m *MapMessage) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { 1346 | return xxx_messageInfo_MapMessage.Marshal(b, m, deterministic) 1347 | } 1348 | func (m *MapMessage) XXX_Merge(src proto.Message) { 1349 | xxx_messageInfo_MapMessage.Merge(m, src) 1350 | } 1351 | func (m *MapMessage) XXX_Size() int { 1352 | return xxx_messageInfo_MapMessage.Size(m) 1353 | } 1354 | func (m *MapMessage) XXX_DiscardUnknown() { 1355 | xxx_messageInfo_MapMessage.DiscardUnknown(m) 1356 | } 1357 | 1358 | var xxx_messageInfo_MapMessage proto.InternalMessageInfo 1359 | 1360 | func (m *MapMessage) GetMappedValue() map[int32]string { 1361 | if m != nil { 1362 | return m.MappedValue 1363 | } 1364 | return nil 1365 | } 1366 | 1367 | func (m *MapMessage) GetMappedEnumValue() map[string]NumericEnum { 1368 | if m != nil { 1369 | return m.MappedEnumValue 1370 | } 1371 | return nil 1372 | } 1373 | 1374 | func (m *MapMessage) GetMappedNestedValue() map[string]*NestedMessage { 1375 | if m != nil { 1376 | return m.MappedNestedValue 1377 | } 1378 | return nil 1379 | } 1380 | 1381 | type NotLoggingMapMessage struct { 1382 | MappedValue map[int32]string `protobuf:"bytes,1,rep,name=mapped_value,json=mappedValue,proto3" json:"mapped_value,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` 1383 | MappedEnumValue map[string]NumericEnum `protobuf:"bytes,2,rep,name=mapped_enum_value,json=mappedEnumValue,proto3" json:"mapped_enum_value,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3,enum=kazegusuri.zapmarshaler.example.NumericEnum"` 1384 | MappedNestedValue map[string]*NestedMessage `protobuf:"bytes,3,rep,name=mapped_nested_value,json=mappedNestedValue,proto3" json:"mapped_nested_value,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` 1385 | XXX_NoUnkeyedLiteral struct{} `json:"-"` 1386 | XXX_unrecognized []byte `json:"-"` 1387 | XXX_sizecache int32 `json:"-"` 1388 | } 1389 | 1390 | func (m *NotLoggingMapMessage) Reset() { *m = NotLoggingMapMessage{} } 1391 | func (m *NotLoggingMapMessage) String() string { return proto.CompactTextString(m) } 1392 | func (*NotLoggingMapMessage) ProtoMessage() {} 1393 | func (*NotLoggingMapMessage) Descriptor() ([]byte, []int) { 1394 | return fileDescriptor_722e198d308550d7, []int{14} 1395 | } 1396 | 1397 | func (m *NotLoggingMapMessage) XXX_Unmarshal(b []byte) error { 1398 | return xxx_messageInfo_NotLoggingMapMessage.Unmarshal(m, b) 1399 | } 1400 | func (m *NotLoggingMapMessage) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { 1401 | return xxx_messageInfo_NotLoggingMapMessage.Marshal(b, m, deterministic) 1402 | } 1403 | func (m *NotLoggingMapMessage) XXX_Merge(src proto.Message) { 1404 | xxx_messageInfo_NotLoggingMapMessage.Merge(m, src) 1405 | } 1406 | func (m *NotLoggingMapMessage) XXX_Size() int { 1407 | return xxx_messageInfo_NotLoggingMapMessage.Size(m) 1408 | } 1409 | func (m *NotLoggingMapMessage) XXX_DiscardUnknown() { 1410 | xxx_messageInfo_NotLoggingMapMessage.DiscardUnknown(m) 1411 | } 1412 | 1413 | var xxx_messageInfo_NotLoggingMapMessage proto.InternalMessageInfo 1414 | 1415 | func (m *NotLoggingMapMessage) GetMappedValue() map[int32]string { 1416 | if m != nil { 1417 | return m.MappedValue 1418 | } 1419 | return nil 1420 | } 1421 | 1422 | func (m *NotLoggingMapMessage) GetMappedEnumValue() map[string]NumericEnum { 1423 | if m != nil { 1424 | return m.MappedEnumValue 1425 | } 1426 | return nil 1427 | } 1428 | 1429 | func (m *NotLoggingMapMessage) GetMappedNestedValue() map[string]*NestedMessage { 1430 | if m != nil { 1431 | return m.MappedNestedValue 1432 | } 1433 | return nil 1434 | } 1435 | 1436 | type JsonNameOptionMessage struct { 1437 | StringValue string `protobuf:"bytes,1,opt,name=string_value,json=renamed_value,proto3" json:"string_value,omitempty"` 1438 | XXX_NoUnkeyedLiteral struct{} `json:"-"` 1439 | XXX_unrecognized []byte `json:"-"` 1440 | XXX_sizecache int32 `json:"-"` 1441 | } 1442 | 1443 | func (m *JsonNameOptionMessage) Reset() { *m = JsonNameOptionMessage{} } 1444 | func (m *JsonNameOptionMessage) String() string { return proto.CompactTextString(m) } 1445 | func (*JsonNameOptionMessage) ProtoMessage() {} 1446 | func (*JsonNameOptionMessage) Descriptor() ([]byte, []int) { 1447 | return fileDescriptor_722e198d308550d7, []int{15} 1448 | } 1449 | 1450 | func (m *JsonNameOptionMessage) XXX_Unmarshal(b []byte) error { 1451 | return xxx_messageInfo_JsonNameOptionMessage.Unmarshal(m, b) 1452 | } 1453 | func (m *JsonNameOptionMessage) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { 1454 | return xxx_messageInfo_JsonNameOptionMessage.Marshal(b, m, deterministic) 1455 | } 1456 | func (m *JsonNameOptionMessage) XXX_Merge(src proto.Message) { 1457 | xxx_messageInfo_JsonNameOptionMessage.Merge(m, src) 1458 | } 1459 | func (m *JsonNameOptionMessage) XXX_Size() int { 1460 | return xxx_messageInfo_JsonNameOptionMessage.Size(m) 1461 | } 1462 | func (m *JsonNameOptionMessage) XXX_DiscardUnknown() { 1463 | xxx_messageInfo_JsonNameOptionMessage.DiscardUnknown(m) 1464 | } 1465 | 1466 | var xxx_messageInfo_JsonNameOptionMessage proto.InternalMessageInfo 1467 | 1468 | func (m *JsonNameOptionMessage) GetStringValue() string { 1469 | if m != nil { 1470 | return m.StringValue 1471 | } 1472 | return "" 1473 | } 1474 | 1475 | type NotLoggingJsonNameOptionMessage struct { 1476 | StringValue string `protobuf:"bytes,1,opt,name=string_value,json=renamed_value,proto3" json:"string_value,omitempty"` 1477 | XXX_NoUnkeyedLiteral struct{} `json:"-"` 1478 | XXX_unrecognized []byte `json:"-"` 1479 | XXX_sizecache int32 `json:"-"` 1480 | } 1481 | 1482 | func (m *NotLoggingJsonNameOptionMessage) Reset() { *m = NotLoggingJsonNameOptionMessage{} } 1483 | func (m *NotLoggingJsonNameOptionMessage) String() string { return proto.CompactTextString(m) } 1484 | func (*NotLoggingJsonNameOptionMessage) ProtoMessage() {} 1485 | func (*NotLoggingJsonNameOptionMessage) Descriptor() ([]byte, []int) { 1486 | return fileDescriptor_722e198d308550d7, []int{16} 1487 | } 1488 | 1489 | func (m *NotLoggingJsonNameOptionMessage) XXX_Unmarshal(b []byte) error { 1490 | return xxx_messageInfo_NotLoggingJsonNameOptionMessage.Unmarshal(m, b) 1491 | } 1492 | func (m *NotLoggingJsonNameOptionMessage) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { 1493 | return xxx_messageInfo_NotLoggingJsonNameOptionMessage.Marshal(b, m, deterministic) 1494 | } 1495 | func (m *NotLoggingJsonNameOptionMessage) XXX_Merge(src proto.Message) { 1496 | xxx_messageInfo_NotLoggingJsonNameOptionMessage.Merge(m, src) 1497 | } 1498 | func (m *NotLoggingJsonNameOptionMessage) XXX_Size() int { 1499 | return xxx_messageInfo_NotLoggingJsonNameOptionMessage.Size(m) 1500 | } 1501 | func (m *NotLoggingJsonNameOptionMessage) XXX_DiscardUnknown() { 1502 | xxx_messageInfo_NotLoggingJsonNameOptionMessage.DiscardUnknown(m) 1503 | } 1504 | 1505 | var xxx_messageInfo_NotLoggingJsonNameOptionMessage proto.InternalMessageInfo 1506 | 1507 | func (m *NotLoggingJsonNameOptionMessage) GetStringValue() string { 1508 | if m != nil { 1509 | return m.StringValue 1510 | } 1511 | return "" 1512 | } 1513 | 1514 | type WellKnownTypeMessage struct { 1515 | Duration *duration.Duration `protobuf:"bytes,1,opt,name=duration,proto3" json:"duration,omitempty"` 1516 | Timestamp *timestamp.Timestamp `protobuf:"bytes,2,opt,name=timestamp,proto3" json:"timestamp,omitempty"` 1517 | XXX_NoUnkeyedLiteral struct{} `json:"-"` 1518 | XXX_unrecognized []byte `json:"-"` 1519 | XXX_sizecache int32 `json:"-"` 1520 | } 1521 | 1522 | func (m *WellKnownTypeMessage) Reset() { *m = WellKnownTypeMessage{} } 1523 | func (m *WellKnownTypeMessage) String() string { return proto.CompactTextString(m) } 1524 | func (*WellKnownTypeMessage) ProtoMessage() {} 1525 | func (*WellKnownTypeMessage) Descriptor() ([]byte, []int) { 1526 | return fileDescriptor_722e198d308550d7, []int{17} 1527 | } 1528 | 1529 | func (m *WellKnownTypeMessage) XXX_Unmarshal(b []byte) error { 1530 | return xxx_messageInfo_WellKnownTypeMessage.Unmarshal(m, b) 1531 | } 1532 | func (m *WellKnownTypeMessage) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { 1533 | return xxx_messageInfo_WellKnownTypeMessage.Marshal(b, m, deterministic) 1534 | } 1535 | func (m *WellKnownTypeMessage) XXX_Merge(src proto.Message) { 1536 | xxx_messageInfo_WellKnownTypeMessage.Merge(m, src) 1537 | } 1538 | func (m *WellKnownTypeMessage) XXX_Size() int { 1539 | return xxx_messageInfo_WellKnownTypeMessage.Size(m) 1540 | } 1541 | func (m *WellKnownTypeMessage) XXX_DiscardUnknown() { 1542 | xxx_messageInfo_WellKnownTypeMessage.DiscardUnknown(m) 1543 | } 1544 | 1545 | var xxx_messageInfo_WellKnownTypeMessage proto.InternalMessageInfo 1546 | 1547 | func (m *WellKnownTypeMessage) GetDuration() *duration.Duration { 1548 | if m != nil { 1549 | return m.Duration 1550 | } 1551 | return nil 1552 | } 1553 | 1554 | func (m *WellKnownTypeMessage) GetTimestamp() *timestamp.Timestamp { 1555 | if m != nil { 1556 | return m.Timestamp 1557 | } 1558 | return nil 1559 | } 1560 | 1561 | type NotLoggingWellKnownTypeMessage struct { 1562 | Duration *duration.Duration `protobuf:"bytes,1,opt,name=duration,proto3" json:"duration,omitempty"` 1563 | Timestamp *timestamp.Timestamp `protobuf:"bytes,2,opt,name=timestamp,proto3" json:"timestamp,omitempty"` 1564 | XXX_NoUnkeyedLiteral struct{} `json:"-"` 1565 | XXX_unrecognized []byte `json:"-"` 1566 | XXX_sizecache int32 `json:"-"` 1567 | } 1568 | 1569 | func (m *NotLoggingWellKnownTypeMessage) Reset() { *m = NotLoggingWellKnownTypeMessage{} } 1570 | func (m *NotLoggingWellKnownTypeMessage) String() string { return proto.CompactTextString(m) } 1571 | func (*NotLoggingWellKnownTypeMessage) ProtoMessage() {} 1572 | func (*NotLoggingWellKnownTypeMessage) Descriptor() ([]byte, []int) { 1573 | return fileDescriptor_722e198d308550d7, []int{18} 1574 | } 1575 | 1576 | func (m *NotLoggingWellKnownTypeMessage) XXX_Unmarshal(b []byte) error { 1577 | return xxx_messageInfo_NotLoggingWellKnownTypeMessage.Unmarshal(m, b) 1578 | } 1579 | func (m *NotLoggingWellKnownTypeMessage) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { 1580 | return xxx_messageInfo_NotLoggingWellKnownTypeMessage.Marshal(b, m, deterministic) 1581 | } 1582 | func (m *NotLoggingWellKnownTypeMessage) XXX_Merge(src proto.Message) { 1583 | xxx_messageInfo_NotLoggingWellKnownTypeMessage.Merge(m, src) 1584 | } 1585 | func (m *NotLoggingWellKnownTypeMessage) XXX_Size() int { 1586 | return xxx_messageInfo_NotLoggingWellKnownTypeMessage.Size(m) 1587 | } 1588 | func (m *NotLoggingWellKnownTypeMessage) XXX_DiscardUnknown() { 1589 | xxx_messageInfo_NotLoggingWellKnownTypeMessage.DiscardUnknown(m) 1590 | } 1591 | 1592 | var xxx_messageInfo_NotLoggingWellKnownTypeMessage proto.InternalMessageInfo 1593 | 1594 | func (m *NotLoggingWellKnownTypeMessage) GetDuration() *duration.Duration { 1595 | if m != nil { 1596 | return m.Duration 1597 | } 1598 | return nil 1599 | } 1600 | 1601 | func (m *NotLoggingWellKnownTypeMessage) GetTimestamp() *timestamp.Timestamp { 1602 | if m != nil { 1603 | return m.Timestamp 1604 | } 1605 | return nil 1606 | } 1607 | 1608 | type MixedLoggingMessage struct { 1609 | StringValue string `protobuf:"bytes,1,opt,name=string_value,json=stringValue,proto3" json:"string_value,omitempty"` 1610 | BoolValue bool `protobuf:"varint,2,opt,name=bool_value,json=boolValue,proto3" json:"bool_value,omitempty"` 1611 | Int32Value int32 `protobuf:"varint,3,opt,name=int32_value,json=int32Value,proto3" json:"int32_value,omitempty"` 1612 | XXX_NoUnkeyedLiteral struct{} `json:"-"` 1613 | XXX_unrecognized []byte `json:"-"` 1614 | XXX_sizecache int32 `json:"-"` 1615 | } 1616 | 1617 | func (m *MixedLoggingMessage) Reset() { *m = MixedLoggingMessage{} } 1618 | func (m *MixedLoggingMessage) String() string { return proto.CompactTextString(m) } 1619 | func (*MixedLoggingMessage) ProtoMessage() {} 1620 | func (*MixedLoggingMessage) Descriptor() ([]byte, []int) { 1621 | return fileDescriptor_722e198d308550d7, []int{19} 1622 | } 1623 | 1624 | func (m *MixedLoggingMessage) XXX_Unmarshal(b []byte) error { 1625 | return xxx_messageInfo_MixedLoggingMessage.Unmarshal(m, b) 1626 | } 1627 | func (m *MixedLoggingMessage) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { 1628 | return xxx_messageInfo_MixedLoggingMessage.Marshal(b, m, deterministic) 1629 | } 1630 | func (m *MixedLoggingMessage) XXX_Merge(src proto.Message) { 1631 | xxx_messageInfo_MixedLoggingMessage.Merge(m, src) 1632 | } 1633 | func (m *MixedLoggingMessage) XXX_Size() int { 1634 | return xxx_messageInfo_MixedLoggingMessage.Size(m) 1635 | } 1636 | func (m *MixedLoggingMessage) XXX_DiscardUnknown() { 1637 | xxx_messageInfo_MixedLoggingMessage.DiscardUnknown(m) 1638 | } 1639 | 1640 | var xxx_messageInfo_MixedLoggingMessage proto.InternalMessageInfo 1641 | 1642 | func (m *MixedLoggingMessage) GetStringValue() string { 1643 | if m != nil { 1644 | return m.StringValue 1645 | } 1646 | return "" 1647 | } 1648 | 1649 | func (m *MixedLoggingMessage) GetBoolValue() bool { 1650 | if m != nil { 1651 | return m.BoolValue 1652 | } 1653 | return false 1654 | } 1655 | 1656 | func (m *MixedLoggingMessage) GetInt32Value() int32 { 1657 | if m != nil { 1658 | return m.Int32Value 1659 | } 1660 | return 0 1661 | } 1662 | 1663 | func init() { 1664 | proto.RegisterEnum("kazegusuri.zapmarshaler.example.NumericEnum", NumericEnum_name, NumericEnum_value) 1665 | proto.RegisterEnum("kazegusuri.zapmarshaler.example.AliasedEnum", AliasedEnum_name, AliasedEnum_value) 1666 | proto.RegisterEnum("kazegusuri.zapmarshaler.example.EnumMessage_Nested", EnumMessage_Nested_name, EnumMessage_Nested_value) 1667 | proto.RegisterEnum("kazegusuri.zapmarshaler.example.NotLoggingEnumMessage_Nested", NotLoggingEnumMessage_Nested_name, NotLoggingEnumMessage_Nested_value) 1668 | proto.RegisterType((*SimpleMessage)(nil), "kazegusuri.zapmarshaler.example.SimpleMessage") 1669 | proto.RegisterType((*NotLoggingSimpleMessage)(nil), "kazegusuri.zapmarshaler.example.NotLoggingSimpleMessage") 1670 | proto.RegisterType((*NumberMessage)(nil), "kazegusuri.zapmarshaler.example.NumberMessage") 1671 | proto.RegisterType((*NotLoggingNumberMessage)(nil), "kazegusuri.zapmarshaler.example.NotLoggingNumberMessage") 1672 | proto.RegisterType((*RepeatedNumberMessage)(nil), "kazegusuri.zapmarshaler.example.RepeatedNumberMessage") 1673 | proto.RegisterType((*NotLoggingRepeatedNumberMessage)(nil), "kazegusuri.zapmarshaler.example.NotLoggingRepeatedNumberMessage") 1674 | proto.RegisterType((*NestedMessage)(nil), "kazegusuri.zapmarshaler.example.NestedMessage") 1675 | proto.RegisterType((*NestedMessage_Nested)(nil), "kazegusuri.zapmarshaler.example.NestedMessage.Nested") 1676 | proto.RegisterType((*NotLoggingNestedMessage)(nil), "kazegusuri.zapmarshaler.example.NotLoggingNestedMessage") 1677 | proto.RegisterType((*NotLoggingNestedMessage_Nested)(nil), "kazegusuri.zapmarshaler.example.NotLoggingNestedMessage.Nested") 1678 | proto.RegisterType((*EnumMessage)(nil), "kazegusuri.zapmarshaler.example.EnumMessage") 1679 | proto.RegisterType((*NotLoggingEnumMessage)(nil), "kazegusuri.zapmarshaler.example.NotLoggingEnumMessage") 1680 | proto.RegisterType((*Oneof)(nil), "kazegusuri.zapmarshaler.example.Oneof") 1681 | proto.RegisterType((*OneofMessage)(nil), "kazegusuri.zapmarshaler.example.OneofMessage") 1682 | proto.RegisterType((*NotLoggingOneofMessage)(nil), "kazegusuri.zapmarshaler.example.NotLoggingOneofMessage") 1683 | proto.RegisterType((*MapMessage)(nil), "kazegusuri.zapmarshaler.example.MapMessage") 1684 | proto.RegisterMapType((map[string]NumericEnum)(nil), "kazegusuri.zapmarshaler.example.MapMessage.MappedEnumValueEntry") 1685 | proto.RegisterMapType((map[string]*NestedMessage)(nil), "kazegusuri.zapmarshaler.example.MapMessage.MappedNestedValueEntry") 1686 | proto.RegisterMapType((map[int32]string)(nil), "kazegusuri.zapmarshaler.example.MapMessage.MappedValueEntry") 1687 | proto.RegisterType((*NotLoggingMapMessage)(nil), "kazegusuri.zapmarshaler.example.NotLoggingMapMessage") 1688 | proto.RegisterMapType((map[string]NumericEnum)(nil), "kazegusuri.zapmarshaler.example.NotLoggingMapMessage.MappedEnumValueEntry") 1689 | proto.RegisterMapType((map[string]*NestedMessage)(nil), "kazegusuri.zapmarshaler.example.NotLoggingMapMessage.MappedNestedValueEntry") 1690 | proto.RegisterMapType((map[int32]string)(nil), "kazegusuri.zapmarshaler.example.NotLoggingMapMessage.MappedValueEntry") 1691 | proto.RegisterType((*JsonNameOptionMessage)(nil), "kazegusuri.zapmarshaler.example.JsonNameOptionMessage") 1692 | proto.RegisterType((*NotLoggingJsonNameOptionMessage)(nil), "kazegusuri.zapmarshaler.example.NotLoggingJsonNameOptionMessage") 1693 | proto.RegisterType((*WellKnownTypeMessage)(nil), "kazegusuri.zapmarshaler.example.WellKnownTypeMessage") 1694 | proto.RegisterType((*NotLoggingWellKnownTypeMessage)(nil), "kazegusuri.zapmarshaler.example.NotLoggingWellKnownTypeMessage") 1695 | proto.RegisterType((*MixedLoggingMessage)(nil), "kazegusuri.zapmarshaler.example.MixedLoggingMessage") 1696 | } 1697 | 1698 | func init() { 1699 | proto.RegisterFile("examples/zap-marshaler/example.proto", fileDescriptor_722e198d308550d7) 1700 | } 1701 | 1702 | var fileDescriptor_722e198d308550d7 = []byte{ 1703 | // 1569 bytes of a gzipped FileDescriptorProto 1704 | 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x59, 0x5d, 0x73, 0xdb, 0xd4, 1705 | 0x16, 0x8d, 0x2c, 0x3b, 0xb1, 0xb7, 0xe4, 0xc4, 0x55, 0x92, 0x5e, 0xd7, 0xf7, 0xde, 0x5a, 0xb6, 1706 | 0x6f, 0x6e, 0x9c, 0x96, 0x3a, 0x43, 0xfa, 0x31, 0x1d, 0x86, 0x42, 0x1b, 0xe2, 0x52, 0xda, 0xc4, 1707 | 0xee, 0xa4, 0x29, 0x9d, 0x09, 0xcc, 0x04, 0x19, 0x2b, 0x46, 0x53, 0xeb, 0x63, 0x7c, 0xa4, 0xd2, 1708 | 0x66, 0xfa, 0xcc, 0x2b, 0xc3, 0x13, 0xc3, 0x13, 0xbf, 0x83, 0xd7, 0xc2, 0x53, 0xf9, 0x05, 0xf0, 1709 | 0x0a, 0x3f, 0x84, 0xd1, 0xe7, 0xd9, 0x47, 0x3e, 0x89, 0xeb, 0x26, 0xbc, 0xf1, 0x16, 0xe9, 0x6c, 1710 | 0xad, 0x75, 0xf6, 0x5e, 0x6b, 0x1f, 0xef, 0x48, 0xf0, 0x3f, 0xfd, 0xb9, 0x66, 0x3a, 0x43, 0x9d, 1711 | 0xac, 0x1f, 0x69, 0xce, 0x15, 0x53, 0x1b, 0x91, 0xaf, 0xb4, 0xa1, 0x3e, 0x5a, 0x8f, 0x6e, 0xb7, 1712 | 0x9c, 0x91, 0xed, 0xda, 0x4a, 0xf5, 0xa9, 0x76, 0xa4, 0x0f, 0x3c, 0xe2, 0x8d, 0x8c, 0xd6, 0x91, 1713 | 0xe6, 0x24, 0x61, 0xad, 0x28, 0xac, 0xb2, 0x78, 0xa4, 0x39, 0x07, 0xf4, 0x76, 0xf0, 0x54, 0xe5, 1714 | 0xe2, 0xc0, 0xb6, 0x07, 0x43, 0x7d, 0x3d, 0xb8, 0xea, 0x79, 0x87, 0xeb, 0x7d, 0x6f, 0xa4, 0xb9, 1715 | 0x86, 0x6d, 0x45, 0xeb, 0xd5, 0xf4, 0xba, 0x6b, 0x98, 0x3a, 0x71, 0x35, 0xd3, 0x09, 0x03, 0xea, 1716 | 0x1a, 0x14, 0x1f, 0x19, 0x3e, 0xfe, 0x8e, 0x4e, 0x88, 0x36, 0xd0, 0x95, 0x35, 0x90, 0x89, 0x3b, 1717 | 0x32, 0xac, 0xc1, 0xc1, 0x33, 0x6d, 0xe8, 0xe9, 0x65, 0x41, 0x15, 0x9a, 0x85, 0xcd, 0xd9, 0xd7, 1718 | 0xaf, 0xaa, 0x99, 0xbc, 0xb0, 0x2b, 0x85, 0x6b, 0x9f, 0xfa, 0x4b, 0xca, 0x0a, 0x40, 0xcf, 0xb6, 1719 | 0x87, 0x51, 0x60, 0x46, 0x15, 0x9a, 0xf9, 0x24, 0xb0, 0xe0, 0xaf, 0x04, 0x61, 0xf5, 0xcf, 0xe0, 1720 | 0x5f, 0x1d, 0xdb, 0xdd, 0xb6, 0x07, 0x03, 0xc3, 0x1a, 0xb0, 0x64, 0x35, 0x1e, 0x19, 0x4b, 0xf2, 1721 | 0xdf, 0x71, 0x12, 0x0c, 0xfe, 0x43, 0x16, 0x8a, 0x1d, 0xcf, 0xec, 0xe9, 0xa3, 0x18, 0x73, 0x15, 1722 | 0xa4, 0xc3, 0xa1, 0xad, 0xb9, 0x08, 0x32, 0x93, 0x6c, 0x0b, 0x82, 0xa5, 0x10, 0x79, 0x0d, 0xe4, 1723 | 0xbe, 0xed, 0xf5, 0x86, 0x3a, 0xc2, 0x16, 0x68, 0xa6, 0xe1, 0x5a, 0x18, 0xba, 0x0a, 0x92, 0x61, 1724 | 0xb9, 0x57, 0x37, 0xa2, 0x48, 0x51, 0x15, 0x9a, 0x39, 0x8a, 0x19, 0x2c, 0xe1, 0xc0, 0x1b, 0xd7, 1725 | 0xa2, 0xc0, 0xac, 0x2a, 0x34, 0x45, 0x26, 0xf0, 0xc6, 0xb5, 0x84, 0xdc, 0xc3, 0x90, 0x39, 0x55, 1726 | 0x68, 0x16, 0x29, 0xb9, 0x87, 0x30, 0xa3, 0xd0, 0x04, 0x74, 0x56, 0x15, 0x9a, 0x59, 0x36, 0x14, 1727 | 0xa1, 0x12, 0x8c, 0x3a, 0xa7, 0x0a, 0xcd, 0x73, 0x48, 0x3c, 0x16, 0x95, 0x60, 0xd4, 0xbc, 0x2a, 1728 | 0x34, 0x15, 0x36, 0x34, 0x46, 0xbd, 0x0c, 0xc5, 0x43, 0xe3, 0xb9, 0xde, 0x4f, 0x60, 0x0b, 0xaa, 1729 | 0xd0, 0x9c, 0x4b, 0x62, 0xe5, 0x68, 0x91, 0x0d, 0x4e, 0x80, 0x41, 0x15, 0x9a, 0xb3, 0xa9, 0xe0, 1730 | 0x18, 0xf9, 0x0a, 0xcc, 0x13, 0x16, 0x5a, 0x52, 0x85, 0xe6, 0x42, 0x12, 0x5d, 0x24, 0x0c, 0x76, 1731 | 0x12, 0x9e, 0x80, 0xcb, 0xaa, 0xd0, 0x2c, 0xa5, 0xc3, 0x23, 0xf4, 0xfa, 0xcf, 0x22, 0x76, 0x1e, 1732 | 0xeb, 0x92, 0x2a, 0xc7, 0x25, 0x8c, 0x3b, 0x6a, 0x3c, 0x77, 0xb0, 0xae, 0xa8, 0x72, 0x5c, 0xc1, 1733 | 0xb8, 0xa1, 0xca, 0x71, 0x03, 0xe3, 0x82, 0x1a, 0xcf, 0x05, 0xac, 0xfa, 0x35, 0x9e, 0xfa, 0xac, 1734 | 0xea, 0x35, 0x9e, 0xea, 0xac, 0xda, 0x35, 0x9e, 0xda, 0xac, 0xca, 0x0d, 0xae, 0xca, 0x29, 0x75, 1735 | 0x1b, 0x5c, 0x75, 0x53, 0xaa, 0xae, 0xf0, 0x55, 0x4d, 0xab, 0xb9, 0xc2, 0x57, 0x33, 0xad, 0xe2, 1736 | 0x4f, 0x59, 0x58, 0xde, 0xd5, 0x1d, 0x5d, 0x73, 0xf5, 0x3e, 0xab, 0xe1, 0x1a, 0xc8, 0x48, 0x43, 1737 | 0x52, 0x16, 0x54, 0x11, 0xb5, 0xba, 0x44, 0xc5, 0x24, 0xbe, 0x2b, 0xb1, 0x9a, 0xa4, 0x9c, 0x51, 1738 | 0x45, 0xd4, 0xec, 0x32, 0x92, 0x95, 0xf8, 0xb8, 0xa8, 0x9c, 0xa4, 0x2c, 0xaa, 0x22, 0x6a, 0x77, 1739 | 0x89, 0x96, 0x35, 0x0e, 0x8d, 0x13, 0x20, 0xe5, 0xac, 0x2a, 0xa2, 0x86, 0x97, 0x68, 0x79, 0x83, 1740 | 0x2d, 0x78, 0x0c, 0x6c, 0x4e, 0x15, 0x51, 0xcb, 0xcb, 0x1e, 0xc6, 0x8d, 0x82, 0x29, 0xf0, 0xac, 1741 | 0x2a, 0xa2, 0xa6, 0x97, 0xbd, 0x14, 0x32, 0x61, 0x90, 0xe7, 0x54, 0x11, 0xb5, 0xbd, 0x4c, 0x52, 1742 | 0xc8, 0x84, 0x41, 0xce, 0xab, 0x22, 0x6a, 0x7c, 0x99, 0x60, 0xe4, 0x2b, 0x30, 0xcf, 0x08, 0x49, 1743 | 0xca, 0x05, 0x55, 0x44, 0xad, 0x5f, 0xc4, 0x82, 0xd2, 0x70, 0x0a, 0x0e, 0xaa, 0x88, 0x9a, 0xbf, 1744 | 0x88, 0x85, 0x25, 0xca, 0x3a, 0x2c, 0x90, 0x14, 0xbc, 0xa4, 0x8a, 0xa8, 0xfd, 0xe7, 0x09, 0x8b, 1745 | 0x9f, 0x3c, 0x40, 0x09, 0x64, 0x55, 0x44, 0x07, 0xc0, 0x3c, 0x63, 0x1d, 0x52, 0xff, 0x43, 0x84, 1746 | 0x2a, 0x3d, 0x01, 0xf8, 0x2e, 0xaa, 0xf1, 0x5c, 0xc4, 0xba, 0xa7, 0xc1, 0x75, 0x4f, 0xca, 0x35, 1747 | 0x35, 0x9e, 0x6b, 0x58, 0xb7, 0xd4, 0x78, 0x6e, 0x61, 0x5d, 0xd2, 0xe0, 0xba, 0x24, 0xe5, 0x8e, 1748 | 0x06, 0xd7, 0x1d, 0x29, 0x57, 0x34, 0xb8, 0xae, 0x48, 0xb9, 0xa1, 0xc1, 0x75, 0x43, 0xca, 0x05, 1749 | 0x2b, 0x7c, 0x17, 0xa4, 0xd5, 0x5f, 0xe1, 0xab, 0x9f, 0x56, 0x7d, 0xf5, 0x18, 0xd5, 0xc7, 0xd4, 1750 | 0x5e, 0x3d, 0x46, 0xed, 0x31, 0x95, 0x7f, 0xc9, 0x40, 0xb1, 0xa3, 0x13, 0x57, 0xef, 0xc7, 0x9a, 1751 | 0x7e, 0x01, 0xb2, 0x15, 0xdc, 0x40, 0xc7, 0xbb, 0xb4, 0x71, 0xbd, 0x35, 0x61, 0xc6, 0x6a, 0x31, 1752 | 0x28, 0xd1, 0x15, 0xed, 0xe6, 0x10, 0x32, 0x3c, 0xbc, 0x08, 0x9c, 0x1f, 0x45, 0x76, 0x3a, 0xc0, 1753 | 0x54, 0xa1, 0x37, 0x4e, 0xcd, 0xb5, 0x14, 0x83, 0x77, 0x28, 0x27, 0xa9, 0x7c, 0x0e, 0xb3, 0xe1, 1754 | 0x75, 0x7a, 0x20, 0x11, 0x8e, 0x1d, 0x48, 0xd2, 0xe3, 0x5c, 0xe6, 0xd8, 0x71, 0xae, 0xfe, 0x2a, 1755 | 0xc3, 0xfc, 0x5c, 0x32, 0x05, 0xed, 0x71, 0x0b, 0xfa, 0xe1, 0xe4, 0x24, 0xf9, 0x78, 0x51, 0xba, 1756 | 0x6c, 0x49, 0xbd, 0x09, 0x25, 0x3d, 0x35, 0x1b, 0xbf, 0xa8, 0xdb, 0x49, 0x51, 0xab, 0x9c, 0xa2, 1757 | 0x32, 0xc5, 0xac, 0xf1, 0x8a, 0xc9, 0x16, 0xf1, 0xcf, 0x2c, 0x48, 0x6d, 0xcb, 0x33, 0x69, 0xe1, 1758 | 0x14, 0xcb, 0x33, 0xf5, 0x91, 0xf1, 0xe5, 0x81, 0x6e, 0x79, 0x26, 0x82, 0x9e, 0xdf, 0x78, 0x67, 1759 | 0x72, 0x42, 0xe1, 0xa3, 0x3e, 0x60, 0xa2, 0x59, 0xc9, 0xa2, 0x37, 0xe3, 0xc2, 0xfd, 0x87, 0x16, 1760 | 0x6e, 0x8c, 0x2c, 0x2c, 0xdf, 0xdb, 0xb2, 0x5d, 0x18, 0xd1, 0x43, 0x93, 0x61, 0x25, 0x7e, 0x6a, 1761 | 0xda, 0xd0, 0xd0, 0x88, 0xde, 0xc7, 0xa9, 0x89, 0x6f, 0x98, 0xda, 0x9d, 0xf0, 0x51, 0x36, 0x35, 1762 | 0x8d, 0xde, 0x0c, 0x53, 0x1b, 0xc0, 0xb9, 0xc8, 0x0a, 0x88, 0x22, 0x1b, 0x50, 0x5c, 0x9d, 0x48, 1763 | 0x81, 0x74, 0x48, 0xf7, 0xd7, 0x42, 0x88, 0x4a, 0x89, 0x8e, 0xe0, 0xdf, 0x69, 0xf3, 0xe1, 0x12, 1764 | 0xe6, 0x82, 0x12, 0x9e, 0x8a, 0xb2, 0xcc, 0xba, 0x8f, 0x16, 0xb2, 0xfe, 0x6e, 0xe2, 0x40, 0x09, 1765 | 0xe6, 0x1e, 0x77, 0x1e, 0x74, 0xba, 0x4f, 0x3a, 0xa5, 0x19, 0xff, 0xe2, 0x61, 0xbb, 0xb3, 0xf5, 1766 | 0x49, 0xe7, 0xe3, 0x92, 0xa0, 0x14, 0xa1, 0xf0, 0x51, 0x77, 0xe7, 0xe1, 0x76, 0x7b, 0xaf, 0xbd, 1767 | 0x55, 0xca, 0xd4, 0x7f, 0xcf, 0xc2, 0x32, 0x75, 0x3b, 0x36, 0xdc, 0xfe, 0x59, 0x19, 0x8e, 0x63, 1768 | 0x34, 0xf3, 0xec, 0x8d, 0x76, 0x92, 0xc1, 0xf6, 0xcf, 0xca, 0x60, 0x1c, 0x63, 0x19, 0xc7, 0x1b, 1769 | 0xeb, 0xd6, 0x14, 0xe7, 0xcc, 0xb8, 0xde, 0xe3, 0xd6, 0x7a, 0xf9, 0x26, 0xd6, 0x3a, 0x25, 0xe9, 1770 | 0x99, 0x9a, 0xcb, 0x82, 0x5c, 0xd7, 0xd2, 0xed, 0x43, 0x65, 0xed, 0x84, 0x5f, 0x99, 0x7b, 0x33, 1771 | 0xcc, 0xd1, 0x78, 0xf9, 0xa4, 0xdf, 0x99, 0x7b, 0x33, 0xcc, 0x21, 0xb9, 0x59, 0x04, 0xc9, 0xf6, 1772 | 0x09, 0xc2, 0xd8, 0xfa, 0x6f, 0x02, 0xc8, 0x01, 0x21, 0x1d, 0xec, 0xff, 0x16, 0x5e, 0xa5, 0x07, 1773 | 0xcb, 0x89, 0x12, 0x68, 0x03, 0xe1, 0xac, 0x26, 0x6d, 0xfc, 0x7f, 0xa2, 0x06, 0xc1, 0x2e, 0x93, 1774 | 0x8e, 0x5e, 0x8c, 0xc1, 0x82, 0xdb, 0x61, 0xbd, 0xd3, 0xb9, 0xfd, 0x2a, 0xc0, 0x79, 0xaa, 0x1c, 1775 | 0x93, 0x65, 0x8d, 0x93, 0x65, 0x2a, 0xbb, 0x06, 0x2f, 0xbb, 0x74, 0x56, 0xfb, 0x67, 0x92, 0xd5, 1776 | 0x1b, 0x65, 0xf3, 0x6d, 0x0e, 0x60, 0x47, 0x73, 0xe2, 0x0c, 0x06, 0x20, 0x9b, 0x9a, 0xe3, 0xa0, 1777 | 0xa9, 0xc0, 0x27, 0x7c, 0x7f, 0x22, 0x21, 0x85, 0xf0, 0xff, 0x74, 0xa2, 0x9f, 0xe2, 0xb6, 0xe5, 1778 | 0x8e, 0x5e, 0xd0, 0xd1, 0xc4, 0xa4, 0x2b, 0x8a, 0x0b, 0xe7, 0x22, 0x22, 0xd4, 0xad, 0xe1, 0x54, 1779 | 0x70, 0x7b, 0x7a, 0xb6, 0xa4, 0x3b, 0x58, 0xc6, 0x05, 0x93, 0x5d, 0x55, 0x8e, 0x60, 0x31, 0x62, 1780 | 0x65, 0x66, 0x9f, 0xb0, 0xac, 0x9b, 0xd3, 0xf3, 0xa2, 0xb1, 0x83, 0x65, 0x8e, 0x92, 0x43, 0xeb, 1781 | 0x95, 0x0f, 0xa0, 0x94, 0x2e, 0x8d, 0x52, 0x02, 0xf1, 0xa9, 0xfe, 0x22, 0x9a, 0x4b, 0xfc, 0x3f, 1782 | 0x95, 0x25, 0xc8, 0xe1, 0x49, 0x24, 0xbc, 0x78, 0x2f, 0x73, 0x53, 0xa8, 0x38, 0xb0, 0xc4, 0x4b, 1783 | 0x16, 0x63, 0x14, 0x42, 0x8c, 0x4d, 0x8c, 0x31, 0xed, 0xe9, 0x8d, 0x18, 0x5d, 0x38, 0xcf, 0x4f, 1784 | 0x93, 0xc3, 0xb9, 0x85, 0x39, 0xa5, 0x8d, 0xd6, 0x74, 0xc3, 0x32, 0x62, 0xad, 0xff, 0x98, 0x83, 1785 | 0x25, 0xda, 0x5f, 0xc8, 0x9b, 0x06, 0xd7, 0x9b, 0x77, 0xa7, 0x38, 0x66, 0x4f, 0x70, 0x29, 0xeb, 1786 | 0xce, 0x67, 0xc7, 0xbb, 0xf3, 0xfe, 0x69, 0xf8, 0x58, 0xe9, 0xc6, 0xfd, 0xf9, 0xf2, 0x24, 0x7f, 1787 | 0x6e, 0x9f, 0x86, 0x39, 0x2d, 0xe1, 0x3f, 0x0e, 0x7d, 0x7b, 0x87, 0x6e, 0xc1, 0xf2, 0x7d, 0x62, 1788 | 0x5b, 0x1d, 0xcd, 0xd4, 0xbb, 0x8e, 0x6b, 0xd8, 0x56, 0xec, 0xd0, 0xcb, 0x27, 0xbe, 0x69, 0x2f, 1789 | 0x8e, 0x74, 0x4b, 0x33, 0x63, 0x51, 0xeb, 0x77, 0xf1, 0x8b, 0x0c, 0x3e, 0x5e, 0x83, 0xfb, 0x32, 1790 | 0x3d, 0x85, 0xf3, 0xbd, 0x00, 0x4b, 0x4f, 0xf4, 0xe1, 0xf0, 0x81, 0x65, 0x7f, 0x6d, 0xed, 0xbd, 1791 | 0x70, 0x92, 0x57, 0xf1, 0xb7, 0x20, 0x1f, 0x7f, 0x3b, 0x88, 0xfe, 0xbb, 0xbb, 0xd0, 0x0a, 0x3f, 1792 | 0x1e, 0xb4, 0xe2, 0x8f, 0x07, 0xad, 0xad, 0x28, 0x20, 0xd9, 0x64, 0xf2, 0x88, 0x72, 0x1b, 0x0a, 1793 | 0xc9, 0xa7, 0x85, 0xa8, 0x66, 0x95, 0xb1, 0xe7, 0xf7, 0xe2, 0x08, 0xfa, 0x99, 0x20, 0x79, 0xa8, 1794 | 0xfe, 0x9d, 0x00, 0x17, 0x69, 0x8a, 0xdc, 0x3d, 0x5e, 0x9f, 0x62, 0x8f, 0x68, 0x6f, 0x37, 0xa7, 1795 | 0xda, 0x1b, 0xde, 0xd3, 0x37, 0x02, 0x2c, 0xee, 0x18, 0xcf, 0xf5, 0x7e, 0xdc, 0x28, 0xd3, 0x7f, 1796 | 0x24, 0x69, 0x70, 0x3e, 0x92, 0x64, 0x5f, 0xbf, 0xaa, 0xce, 0xa0, 0xaf, 0x18, 0x13, 0xdf, 0x24, 1797 | 0x5f, 0x5a, 0x03, 0x09, 0x99, 0x5a, 0xc9, 0x43, 0x76, 0xbf, 0xbd, 0xdb, 0x2d, 0xcd, 0x28, 0x73, 1798 | 0x20, 0x76, 0x3b, 0xed, 0x92, 0xe0, 0xff, 0xb1, 0xf7, 0xa4, 0x5b, 0xca, 0x5c, 0xba, 0x09, 0x12, 1799 | 0x1a, 0x7d, 0xc7, 0xa6, 0xbe, 0x47, 0x7b, 0x77, 0x76, 0xfd, 0x31, 0x4f, 0xf0, 0x2f, 0x76, 0x1f, 1800 | 0x77, 0x3a, 0xc1, 0x08, 0x58, 0xc9, 0x94, 0x84, 0x4d, 0xd8, 0xcf, 0xc7, 0x9f, 0xaa, 0x7a, 0xb3, 1801 | 0x41, 0x61, 0xae, 0xfe, 0x15, 0x00, 0x00, 0xff, 0xff, 0x06, 0x8e, 0x0d, 0x56, 0xbd, 0x1a, 0x00, 1802 | 0x00, 1803 | } 1804 | -------------------------------------------------------------------------------- /examples/zap-marshaler/example.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package kazegusuri.zapmarshaler.example; 4 | option go_package = "examples"; 5 | 6 | import "zap_marshaler.proto"; 7 | import "google/protobuf/duration.proto"; 8 | import "google/protobuf/timestamp.proto"; 9 | 10 | message SimpleMessage { 11 | string string_value = 1 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 12 | bool bool_value = 2 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 13 | } 14 | 15 | message NotLoggingSimpleMessage { 16 | string string_value = 1; 17 | bool bool_value = 2; 18 | } 19 | 20 | message NumberMessage { 21 | float float_value = 1 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 22 | double double_value = 2 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 23 | 24 | int32 int32_value = 3 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 25 | int64 int64_value = 4 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 26 | uint32 uint32_value = 5 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 27 | uint64 uint64_value = 6 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 28 | sint32 sint32_value = 7 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 29 | sint64 sint64_value = 8 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 30 | 31 | fixed32 fixed32_value = 9 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 32 | fixed64 fixed64_value = 10 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 33 | sfixed32 sfixed32_value = 11 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 34 | sfixed64 sfixed64_value = 12 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 35 | } 36 | 37 | message NotLoggingNumberMessage { 38 | float float_value = 1; 39 | double double_value = 2; 40 | 41 | int32 int32_value = 3; 42 | int64 int64_value = 4; 43 | uint32 uint32_value = 5; 44 | uint64 uint64_value = 6; 45 | sint32 sint32_value = 7; 46 | sint64 sint64_value = 8; 47 | 48 | fixed32 fixed32_value = 9; 49 | fixed64 fixed64_value = 10; 50 | sfixed32 sfixed32_value = 11; 51 | sfixed64 sfixed64_value = 12; 52 | } 53 | 54 | message RepeatedNumberMessage { 55 | repeated float float_values = 1 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 56 | repeated double double_values = 2 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 57 | 58 | repeated int32 int32_values = 3 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 59 | repeated int64 int64_values = 4 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 60 | repeated uint32 uint32_values = 5 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 61 | repeated uint64 uint64_values = 6 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 62 | repeated sint32 sint32_values = 7 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 63 | repeated sint64 sint64_values = 8 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 64 | 65 | repeated fixed32 fixed32_values = 9 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 66 | repeated fixed64 fixed64_values = 10 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 67 | repeated sfixed32 sfixed32_values = 11 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 68 | repeated sfixed64 sfixed64_values = 12 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 69 | } 70 | 71 | message NotLoggingRepeatedNumberMessage { 72 | repeated float float_values = 1; 73 | repeated double double_values = 2; 74 | 75 | repeated int32 int32_values = 3; 76 | repeated int64 int64_values = 4; 77 | repeated uint32 uint32_values = 5; 78 | repeated uint64 uint64_values = 6; 79 | repeated sint32 sint32_values = 7; 80 | repeated sint64 sint64_values = 8; 81 | 82 | repeated fixed32 fixed32_values = 9; 83 | repeated fixed64 fixed64_values = 10; 84 | repeated sfixed32 sfixed32_values = 11; 85 | repeated sfixed64 sfixed64_values = 12; 86 | } 87 | 88 | message NestedMessage { 89 | message Nested { 90 | int32 int32_value = 1 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 91 | string string_value = 2 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 92 | } 93 | Nested nested_value = 1 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 94 | repeated Nested repeated_nested_values = 2 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 95 | } 96 | 97 | message NotLoggingNestedMessage { 98 | message Nested { 99 | int32 int32_value = 1; 100 | string string_value = 2; 101 | } 102 | Nested nested_value = 1; 103 | repeated Nested repeated_nested_values = 2; 104 | } 105 | 106 | message EnumMessage { 107 | NumericEnum numeric_enum_value = 1 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 108 | repeated NumericEnum repeated_numeric_enum_values = 2 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 109 | 110 | AliasedEnum aliased_enum_value = 3 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 111 | 112 | enum Nested { 113 | UNKNOWN = 0; 114 | PENDING = 1; 115 | COMPLETED = 2; 116 | } 117 | Nested nested_enum_value = 4 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 118 | repeated Nested repeated_nested_enum_values = 5 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 119 | } 120 | 121 | message NotLoggingEnumMessage { 122 | NumericEnum numeric_enum_value = 1; 123 | repeated NumericEnum repeated_numeric_enum_values = 2; 124 | 125 | AliasedEnum aliased_enum_value = 3; 126 | 127 | enum Nested { 128 | UNKNOWN = 0; 129 | PENDING = 1; 130 | COMPLETED = 2; 131 | } 132 | Nested nested_enum_value = 4; 133 | repeated Nested repeated_nested_enum_values = 5; 134 | } 135 | 136 | enum NumericEnum { 137 | ZERO = 0; 138 | ONE = 1; 139 | TWO = 2; 140 | } 141 | 142 | enum AliasedEnum { 143 | option allow_alias = true; 144 | UNKNOWN = 0; 145 | STARTED = 1; 146 | RUNNING = 1; 147 | } 148 | 149 | message Oneof { 150 | oneof oneof_value { 151 | int32 int32_value = 1 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 152 | string string_value = 2 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 153 | } 154 | } 155 | 156 | message OneofMessage { 157 | oneof oneof_value { 158 | int32 int32_value = 1 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 159 | string string_value = 2 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 160 | } 161 | 162 | repeated Oneof repeated_oneof_values = 3 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 163 | } 164 | 165 | message NotLoggingOneofMessage { 166 | oneof oneof_value { 167 | int32 int32_value = 1; 168 | string string_value = 2; 169 | } 170 | 171 | repeated Oneof repeated_oneof_values = 3; 172 | } 173 | 174 | message MapMessage { 175 | map mapped_value = 1 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 176 | map mapped_enum_value = 2 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 177 | map mapped_nested_value = 3 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 178 | } 179 | 180 | message NotLoggingMapMessage { 181 | map mapped_value = 1; 182 | map mapped_enum_value = 2; 183 | map mapped_nested_value = 3; 184 | } 185 | 186 | message JsonNameOptionMessage { 187 | string string_value = 1 [json_name="renamed_value", (kazegusuri.zap_mashaler.field) = {enabled: true}]; 188 | } 189 | 190 | message NotLoggingJsonNameOptionMessage { 191 | string string_value = 1 [json_name="renamed_value"]; 192 | } 193 | 194 | message WellKnownTypeMessage { 195 | google.protobuf.Duration duration = 1 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 196 | google.protobuf.Timestamp timestamp = 2 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 197 | } 198 | 199 | message NotLoggingWellKnownTypeMessage { 200 | google.protobuf.Duration duration = 1; 201 | google.protobuf.Timestamp timestamp = 2; 202 | } 203 | 204 | message MixedLoggingMessage { 205 | string string_value = 1 [(kazegusuri.zap_mashaler.field) = {enabled: true}]; 206 | bool bool_value = 2 [(kazegusuri.zap_mashaler.field) = {enabled: false}]; 207 | int32 int32_value = 3; 208 | } 209 | -------------------------------------------------------------------------------- /examples/zap-marshaler/example.zap.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoc-gen-gogo. DO NOT EDIT. 2 | // source: examples/zap-marshaler/example.proto 3 | 4 | package examples 5 | 6 | import go_uber_org_zap_zapcore "go.uber.org/zap/zapcore" 7 | import github_com_golang_protobuf_ptypes "github.com/golang/protobuf/ptypes" 8 | import proto "github.com/golang/protobuf/proto" 9 | import fmt "fmt" 10 | import math "math" 11 | import _ "github.com/golang/protobuf/ptypes/duration" 12 | import _ "github.com/golang/protobuf/ptypes/timestamp" 13 | import _ "github.com/kazegusuri/go-proto-zap-marshaler" 14 | 15 | // Reference imports to suppress errors if they are not otherwise used. 16 | var _ = proto.Marshal 17 | var _ = fmt.Errorf 18 | var _ = math.Inf 19 | 20 | func (m *SimpleMessage) MarshalLogObject(enc go_uber_org_zap_zapcore.ObjectEncoder) error { 21 | var keyName string 22 | _ = keyName 23 | 24 | keyName = "string_value" // field string_value = 1 25 | enc.AddString(keyName, m.StringValue) 26 | 27 | keyName = "bool_value" // field bool_value = 2 28 | enc.AddBool(keyName, m.BoolValue) 29 | 30 | return nil 31 | } 32 | 33 | func (m *NotLoggingSimpleMessage) MarshalLogObject(enc go_uber_org_zap_zapcore.ObjectEncoder) error { 34 | var keyName string 35 | _ = keyName 36 | 37 | keyName = "string_value" // field string_value = 1 38 | enc.AddString(keyName, m.StringValue) 39 | 40 | keyName = "bool_value" // field bool_value = 2 41 | enc.AddBool(keyName, m.BoolValue) 42 | 43 | return nil 44 | } 45 | 46 | func (m *NumberMessage) MarshalLogObject(enc go_uber_org_zap_zapcore.ObjectEncoder) error { 47 | var keyName string 48 | _ = keyName 49 | 50 | keyName = "float_value" // field float_value = 1 51 | enc.AddFloat32(keyName, m.FloatValue) 52 | 53 | keyName = "double_value" // field double_value = 2 54 | enc.AddFloat64(keyName, m.DoubleValue) 55 | 56 | keyName = "int32_value" // field int32_value = 3 57 | enc.AddInt32(keyName, m.Int32Value) 58 | 59 | keyName = "int64_value" // field int64_value = 4 60 | enc.AddInt64(keyName, m.Int64Value) 61 | 62 | keyName = "uint32_value" // field uint32_value = 5 63 | enc.AddUint32(keyName, m.Uint32Value) 64 | 65 | keyName = "uint64_value" // field uint64_value = 6 66 | enc.AddUint64(keyName, m.Uint64Value) 67 | 68 | keyName = "sint32_value" // field sint32_value = 7 69 | enc.AddInt32(keyName, m.Sint32Value) 70 | 71 | keyName = "sint64_value" // field sint64_value = 8 72 | enc.AddInt64(keyName, m.Sint64Value) 73 | 74 | keyName = "fixed32_value" // field fixed32_value = 9 75 | enc.AddUint32(keyName, m.Fixed32Value) 76 | 77 | keyName = "fixed64_value" // field fixed64_value = 10 78 | enc.AddUint64(keyName, m.Fixed64Value) 79 | 80 | keyName = "sfixed32_value" // field sfixed32_value = 11 81 | enc.AddInt32(keyName, m.Sfixed32Value) 82 | 83 | keyName = "sfixed64_value" // field sfixed64_value = 12 84 | enc.AddInt64(keyName, m.Sfixed64Value) 85 | 86 | return nil 87 | } 88 | 89 | func (m *NotLoggingNumberMessage) MarshalLogObject(enc go_uber_org_zap_zapcore.ObjectEncoder) error { 90 | var keyName string 91 | _ = keyName 92 | 93 | keyName = "float_value" // field float_value = 1 94 | enc.AddFloat32(keyName, m.FloatValue) 95 | 96 | keyName = "double_value" // field double_value = 2 97 | enc.AddFloat64(keyName, m.DoubleValue) 98 | 99 | keyName = "int32_value" // field int32_value = 3 100 | enc.AddInt32(keyName, m.Int32Value) 101 | 102 | keyName = "int64_value" // field int64_value = 4 103 | enc.AddInt64(keyName, m.Int64Value) 104 | 105 | keyName = "uint32_value" // field uint32_value = 5 106 | enc.AddUint32(keyName, m.Uint32Value) 107 | 108 | keyName = "uint64_value" // field uint64_value = 6 109 | enc.AddUint64(keyName, m.Uint64Value) 110 | 111 | keyName = "sint32_value" // field sint32_value = 7 112 | enc.AddInt32(keyName, m.Sint32Value) 113 | 114 | keyName = "sint64_value" // field sint64_value = 8 115 | enc.AddInt64(keyName, m.Sint64Value) 116 | 117 | keyName = "fixed32_value" // field fixed32_value = 9 118 | enc.AddUint32(keyName, m.Fixed32Value) 119 | 120 | keyName = "fixed64_value" // field fixed64_value = 10 121 | enc.AddUint64(keyName, m.Fixed64Value) 122 | 123 | keyName = "sfixed32_value" // field sfixed32_value = 11 124 | enc.AddInt32(keyName, m.Sfixed32Value) 125 | 126 | keyName = "sfixed64_value" // field sfixed64_value = 12 127 | enc.AddInt64(keyName, m.Sfixed64Value) 128 | 129 | return nil 130 | } 131 | 132 | func (m *RepeatedNumberMessage) MarshalLogObject(enc go_uber_org_zap_zapcore.ObjectEncoder) error { 133 | var keyName string 134 | _ = keyName 135 | 136 | keyName = "float_values" // field float_values = 1 137 | enc.AddArray(keyName, go_uber_org_zap_zapcore.ArrayMarshalerFunc(func(aenc go_uber_org_zap_zapcore.ArrayEncoder) error { 138 | for _, rv := range m.FloatValues { 139 | _ = rv 140 | aenc.AppendFloat32(rv) 141 | } 142 | return nil 143 | })) 144 | 145 | keyName = "double_values" // field double_values = 2 146 | enc.AddArray(keyName, go_uber_org_zap_zapcore.ArrayMarshalerFunc(func(aenc go_uber_org_zap_zapcore.ArrayEncoder) error { 147 | for _, rv := range m.DoubleValues { 148 | _ = rv 149 | aenc.AppendFloat64(rv) 150 | } 151 | return nil 152 | })) 153 | 154 | keyName = "int32_values" // field int32_values = 3 155 | enc.AddArray(keyName, go_uber_org_zap_zapcore.ArrayMarshalerFunc(func(aenc go_uber_org_zap_zapcore.ArrayEncoder) error { 156 | for _, rv := range m.Int32Values { 157 | _ = rv 158 | aenc.AppendInt32(rv) 159 | } 160 | return nil 161 | })) 162 | 163 | keyName = "int64_values" // field int64_values = 4 164 | enc.AddArray(keyName, go_uber_org_zap_zapcore.ArrayMarshalerFunc(func(aenc go_uber_org_zap_zapcore.ArrayEncoder) error { 165 | for _, rv := range m.Int64Values { 166 | _ = rv 167 | aenc.AppendInt64(rv) 168 | } 169 | return nil 170 | })) 171 | 172 | keyName = "uint32_values" // field uint32_values = 5 173 | enc.AddArray(keyName, go_uber_org_zap_zapcore.ArrayMarshalerFunc(func(aenc go_uber_org_zap_zapcore.ArrayEncoder) error { 174 | for _, rv := range m.Uint32Values { 175 | _ = rv 176 | aenc.AppendUint32(rv) 177 | } 178 | return nil 179 | })) 180 | 181 | keyName = "uint64_values" // field uint64_values = 6 182 | enc.AddArray(keyName, go_uber_org_zap_zapcore.ArrayMarshalerFunc(func(aenc go_uber_org_zap_zapcore.ArrayEncoder) error { 183 | for _, rv := range m.Uint64Values { 184 | _ = rv 185 | aenc.AppendUint64(rv) 186 | } 187 | return nil 188 | })) 189 | 190 | keyName = "sint32_values" // field sint32_values = 7 191 | enc.AddArray(keyName, go_uber_org_zap_zapcore.ArrayMarshalerFunc(func(aenc go_uber_org_zap_zapcore.ArrayEncoder) error { 192 | for _, rv := range m.Sint32Values { 193 | _ = rv 194 | aenc.AppendInt32(rv) 195 | } 196 | return nil 197 | })) 198 | 199 | keyName = "sint64_values" // field sint64_values = 8 200 | enc.AddArray(keyName, go_uber_org_zap_zapcore.ArrayMarshalerFunc(func(aenc go_uber_org_zap_zapcore.ArrayEncoder) error { 201 | for _, rv := range m.Sint64Values { 202 | _ = rv 203 | aenc.AppendInt64(rv) 204 | } 205 | return nil 206 | })) 207 | 208 | keyName = "fixed32_values" // field fixed32_values = 9 209 | enc.AddArray(keyName, go_uber_org_zap_zapcore.ArrayMarshalerFunc(func(aenc go_uber_org_zap_zapcore.ArrayEncoder) error { 210 | for _, rv := range m.Fixed32Values { 211 | _ = rv 212 | aenc.AppendUint32(rv) 213 | } 214 | return nil 215 | })) 216 | 217 | keyName = "fixed64_values" // field fixed64_values = 10 218 | enc.AddArray(keyName, go_uber_org_zap_zapcore.ArrayMarshalerFunc(func(aenc go_uber_org_zap_zapcore.ArrayEncoder) error { 219 | for _, rv := range m.Fixed64Values { 220 | _ = rv 221 | aenc.AppendUint64(rv) 222 | } 223 | return nil 224 | })) 225 | 226 | keyName = "sfixed32_values" // field sfixed32_values = 11 227 | enc.AddArray(keyName, go_uber_org_zap_zapcore.ArrayMarshalerFunc(func(aenc go_uber_org_zap_zapcore.ArrayEncoder) error { 228 | for _, rv := range m.Sfixed32Values { 229 | _ = rv 230 | aenc.AppendInt32(rv) 231 | } 232 | return nil 233 | })) 234 | 235 | keyName = "sfixed64_values" // field sfixed64_values = 12 236 | enc.AddArray(keyName, go_uber_org_zap_zapcore.ArrayMarshalerFunc(func(aenc go_uber_org_zap_zapcore.ArrayEncoder) error { 237 | for _, rv := range m.Sfixed64Values { 238 | _ = rv 239 | aenc.AppendInt64(rv) 240 | } 241 | return nil 242 | })) 243 | 244 | return nil 245 | } 246 | 247 | func (m *NotLoggingRepeatedNumberMessage) MarshalLogObject(enc go_uber_org_zap_zapcore.ObjectEncoder) error { 248 | var keyName string 249 | _ = keyName 250 | 251 | keyName = "float_values" // field float_values = 1 252 | enc.AddArray(keyName, go_uber_org_zap_zapcore.ArrayMarshalerFunc(func(aenc go_uber_org_zap_zapcore.ArrayEncoder) error { 253 | for _, rv := range m.FloatValues { 254 | _ = rv 255 | aenc.AppendFloat32(rv) 256 | } 257 | return nil 258 | })) 259 | 260 | keyName = "double_values" // field double_values = 2 261 | enc.AddArray(keyName, go_uber_org_zap_zapcore.ArrayMarshalerFunc(func(aenc go_uber_org_zap_zapcore.ArrayEncoder) error { 262 | for _, rv := range m.DoubleValues { 263 | _ = rv 264 | aenc.AppendFloat64(rv) 265 | } 266 | return nil 267 | })) 268 | 269 | keyName = "int32_values" // field int32_values = 3 270 | enc.AddArray(keyName, go_uber_org_zap_zapcore.ArrayMarshalerFunc(func(aenc go_uber_org_zap_zapcore.ArrayEncoder) error { 271 | for _, rv := range m.Int32Values { 272 | _ = rv 273 | aenc.AppendInt32(rv) 274 | } 275 | return nil 276 | })) 277 | 278 | keyName = "int64_values" // field int64_values = 4 279 | enc.AddArray(keyName, go_uber_org_zap_zapcore.ArrayMarshalerFunc(func(aenc go_uber_org_zap_zapcore.ArrayEncoder) error { 280 | for _, rv := range m.Int64Values { 281 | _ = rv 282 | aenc.AppendInt64(rv) 283 | } 284 | return nil 285 | })) 286 | 287 | keyName = "uint32_values" // field uint32_values = 5 288 | enc.AddArray(keyName, go_uber_org_zap_zapcore.ArrayMarshalerFunc(func(aenc go_uber_org_zap_zapcore.ArrayEncoder) error { 289 | for _, rv := range m.Uint32Values { 290 | _ = rv 291 | aenc.AppendUint32(rv) 292 | } 293 | return nil 294 | })) 295 | 296 | keyName = "uint64_values" // field uint64_values = 6 297 | enc.AddArray(keyName, go_uber_org_zap_zapcore.ArrayMarshalerFunc(func(aenc go_uber_org_zap_zapcore.ArrayEncoder) error { 298 | for _, rv := range m.Uint64Values { 299 | _ = rv 300 | aenc.AppendUint64(rv) 301 | } 302 | return nil 303 | })) 304 | 305 | keyName = "sint32_values" // field sint32_values = 7 306 | enc.AddArray(keyName, go_uber_org_zap_zapcore.ArrayMarshalerFunc(func(aenc go_uber_org_zap_zapcore.ArrayEncoder) error { 307 | for _, rv := range m.Sint32Values { 308 | _ = rv 309 | aenc.AppendInt32(rv) 310 | } 311 | return nil 312 | })) 313 | 314 | keyName = "sint64_values" // field sint64_values = 8 315 | enc.AddArray(keyName, go_uber_org_zap_zapcore.ArrayMarshalerFunc(func(aenc go_uber_org_zap_zapcore.ArrayEncoder) error { 316 | for _, rv := range m.Sint64Values { 317 | _ = rv 318 | aenc.AppendInt64(rv) 319 | } 320 | return nil 321 | })) 322 | 323 | keyName = "fixed32_values" // field fixed32_values = 9 324 | enc.AddArray(keyName, go_uber_org_zap_zapcore.ArrayMarshalerFunc(func(aenc go_uber_org_zap_zapcore.ArrayEncoder) error { 325 | for _, rv := range m.Fixed32Values { 326 | _ = rv 327 | aenc.AppendUint32(rv) 328 | } 329 | return nil 330 | })) 331 | 332 | keyName = "fixed64_values" // field fixed64_values = 10 333 | enc.AddArray(keyName, go_uber_org_zap_zapcore.ArrayMarshalerFunc(func(aenc go_uber_org_zap_zapcore.ArrayEncoder) error { 334 | for _, rv := range m.Fixed64Values { 335 | _ = rv 336 | aenc.AppendUint64(rv) 337 | } 338 | return nil 339 | })) 340 | 341 | keyName = "sfixed32_values" // field sfixed32_values = 11 342 | enc.AddArray(keyName, go_uber_org_zap_zapcore.ArrayMarshalerFunc(func(aenc go_uber_org_zap_zapcore.ArrayEncoder) error { 343 | for _, rv := range m.Sfixed32Values { 344 | _ = rv 345 | aenc.AppendInt32(rv) 346 | } 347 | return nil 348 | })) 349 | 350 | keyName = "sfixed64_values" // field sfixed64_values = 12 351 | enc.AddArray(keyName, go_uber_org_zap_zapcore.ArrayMarshalerFunc(func(aenc go_uber_org_zap_zapcore.ArrayEncoder) error { 352 | for _, rv := range m.Sfixed64Values { 353 | _ = rv 354 | aenc.AppendInt64(rv) 355 | } 356 | return nil 357 | })) 358 | 359 | return nil 360 | } 361 | 362 | func (m *NestedMessage) MarshalLogObject(enc go_uber_org_zap_zapcore.ObjectEncoder) error { 363 | var keyName string 364 | _ = keyName 365 | 366 | keyName = "nested_value" // field nested_value = 1 367 | if m.NestedValue != nil { 368 | var vv interface{} = m.NestedValue 369 | if marshaler, ok := vv.(go_uber_org_zap_zapcore.ObjectMarshaler); ok { 370 | enc.AddObject(keyName, marshaler) 371 | } 372 | } 373 | 374 | keyName = "repeated_nested_values" // field repeated_nested_values = 2 375 | enc.AddArray(keyName, go_uber_org_zap_zapcore.ArrayMarshalerFunc(func(aenc go_uber_org_zap_zapcore.ArrayEncoder) error { 376 | for _, rv := range m.RepeatedNestedValues { 377 | _ = rv 378 | if rv != nil { 379 | var vv interface{} = rv 380 | if marshaler, ok := vv.(go_uber_org_zap_zapcore.ObjectMarshaler); ok { 381 | aenc.AppendObject(marshaler) 382 | } 383 | } 384 | } 385 | return nil 386 | })) 387 | 388 | return nil 389 | } 390 | 391 | func (m *NestedMessage_Nested) MarshalLogObject(enc go_uber_org_zap_zapcore.ObjectEncoder) error { 392 | var keyName string 393 | _ = keyName 394 | 395 | keyName = "int32_value" // field int32_value = 1 396 | enc.AddInt32(keyName, m.Int32Value) 397 | 398 | keyName = "string_value" // field string_value = 2 399 | enc.AddString(keyName, m.StringValue) 400 | 401 | return nil 402 | } 403 | 404 | func (m *NotLoggingNestedMessage) MarshalLogObject(enc go_uber_org_zap_zapcore.ObjectEncoder) error { 405 | var keyName string 406 | _ = keyName 407 | 408 | keyName = "nested_value" // field nested_value = 1 409 | if m.NestedValue != nil { 410 | var vv interface{} = m.NestedValue 411 | if marshaler, ok := vv.(go_uber_org_zap_zapcore.ObjectMarshaler); ok { 412 | enc.AddObject(keyName, marshaler) 413 | } 414 | } 415 | 416 | keyName = "repeated_nested_values" // field repeated_nested_values = 2 417 | enc.AddArray(keyName, go_uber_org_zap_zapcore.ArrayMarshalerFunc(func(aenc go_uber_org_zap_zapcore.ArrayEncoder) error { 418 | for _, rv := range m.RepeatedNestedValues { 419 | _ = rv 420 | if rv != nil { 421 | var vv interface{} = rv 422 | if marshaler, ok := vv.(go_uber_org_zap_zapcore.ObjectMarshaler); ok { 423 | aenc.AppendObject(marshaler) 424 | } 425 | } 426 | } 427 | return nil 428 | })) 429 | 430 | return nil 431 | } 432 | 433 | func (m *NotLoggingNestedMessage_Nested) MarshalLogObject(enc go_uber_org_zap_zapcore.ObjectEncoder) error { 434 | var keyName string 435 | _ = keyName 436 | 437 | keyName = "int32_value" // field int32_value = 1 438 | enc.AddInt32(keyName, m.Int32Value) 439 | 440 | keyName = "string_value" // field string_value = 2 441 | enc.AddString(keyName, m.StringValue) 442 | 443 | return nil 444 | } 445 | 446 | func (m *EnumMessage) MarshalLogObject(enc go_uber_org_zap_zapcore.ObjectEncoder) error { 447 | var keyName string 448 | _ = keyName 449 | 450 | keyName = "numeric_enum_value" // field numeric_enum_value = 1 451 | enc.AddString(keyName, m.NumericEnumValue.String()) 452 | 453 | keyName = "repeated_numeric_enum_values" // field repeated_numeric_enum_values = 2 454 | enc.AddArray(keyName, go_uber_org_zap_zapcore.ArrayMarshalerFunc(func(aenc go_uber_org_zap_zapcore.ArrayEncoder) error { 455 | for _, rv := range m.RepeatedNumericEnumValues { 456 | _ = rv 457 | aenc.AppendString(rv.String()) 458 | } 459 | return nil 460 | })) 461 | 462 | keyName = "aliased_enum_value" // field aliased_enum_value = 3 463 | enc.AddString(keyName, m.AliasedEnumValue.String()) 464 | 465 | keyName = "nested_enum_value" // field nested_enum_value = 4 466 | enc.AddString(keyName, m.NestedEnumValue.String()) 467 | 468 | keyName = "repeated_nested_enum_values" // field repeated_nested_enum_values = 5 469 | enc.AddArray(keyName, go_uber_org_zap_zapcore.ArrayMarshalerFunc(func(aenc go_uber_org_zap_zapcore.ArrayEncoder) error { 470 | for _, rv := range m.RepeatedNestedEnumValues { 471 | _ = rv 472 | aenc.AppendString(rv.String()) 473 | } 474 | return nil 475 | })) 476 | 477 | return nil 478 | } 479 | 480 | func (m *NotLoggingEnumMessage) MarshalLogObject(enc go_uber_org_zap_zapcore.ObjectEncoder) error { 481 | var keyName string 482 | _ = keyName 483 | 484 | keyName = "numeric_enum_value" // field numeric_enum_value = 1 485 | enc.AddString(keyName, m.NumericEnumValue.String()) 486 | 487 | keyName = "repeated_numeric_enum_values" // field repeated_numeric_enum_values = 2 488 | enc.AddArray(keyName, go_uber_org_zap_zapcore.ArrayMarshalerFunc(func(aenc go_uber_org_zap_zapcore.ArrayEncoder) error { 489 | for _, rv := range m.RepeatedNumericEnumValues { 490 | _ = rv 491 | aenc.AppendString(rv.String()) 492 | } 493 | return nil 494 | })) 495 | 496 | keyName = "aliased_enum_value" // field aliased_enum_value = 3 497 | enc.AddString(keyName, m.AliasedEnumValue.String()) 498 | 499 | keyName = "nested_enum_value" // field nested_enum_value = 4 500 | enc.AddString(keyName, m.NestedEnumValue.String()) 501 | 502 | keyName = "repeated_nested_enum_values" // field repeated_nested_enum_values = 5 503 | enc.AddArray(keyName, go_uber_org_zap_zapcore.ArrayMarshalerFunc(func(aenc go_uber_org_zap_zapcore.ArrayEncoder) error { 504 | for _, rv := range m.RepeatedNestedEnumValues { 505 | _ = rv 506 | aenc.AppendString(rv.String()) 507 | } 508 | return nil 509 | })) 510 | 511 | return nil 512 | } 513 | 514 | func (m *Oneof) MarshalLogObject(enc go_uber_org_zap_zapcore.ObjectEncoder) error { 515 | var keyName string 516 | _ = keyName 517 | 518 | keyName = "int32_value" // field int32_value = 1 519 | if ov, ok := m.GetOneofValue().(*Oneof_Int32Value); ok { 520 | _ = ov 521 | enc.AddInt32(keyName, ov.Int32Value) 522 | } 523 | 524 | keyName = "string_value" // field string_value = 2 525 | if ov, ok := m.GetOneofValue().(*Oneof_StringValue); ok { 526 | _ = ov 527 | enc.AddString(keyName, ov.StringValue) 528 | } 529 | 530 | return nil 531 | } 532 | 533 | func (m *OneofMessage) MarshalLogObject(enc go_uber_org_zap_zapcore.ObjectEncoder) error { 534 | var keyName string 535 | _ = keyName 536 | 537 | keyName = "int32_value" // field int32_value = 1 538 | if ov, ok := m.GetOneofValue().(*OneofMessage_Int32Value); ok { 539 | _ = ov 540 | enc.AddInt32(keyName, ov.Int32Value) 541 | } 542 | 543 | keyName = "string_value" // field string_value = 2 544 | if ov, ok := m.GetOneofValue().(*OneofMessage_StringValue); ok { 545 | _ = ov 546 | enc.AddString(keyName, ov.StringValue) 547 | } 548 | 549 | keyName = "repeated_oneof_values" // field repeated_oneof_values = 3 550 | enc.AddArray(keyName, go_uber_org_zap_zapcore.ArrayMarshalerFunc(func(aenc go_uber_org_zap_zapcore.ArrayEncoder) error { 551 | for _, rv := range m.RepeatedOneofValues { 552 | _ = rv 553 | if rv != nil { 554 | var vv interface{} = rv 555 | if marshaler, ok := vv.(go_uber_org_zap_zapcore.ObjectMarshaler); ok { 556 | aenc.AppendObject(marshaler) 557 | } 558 | } 559 | } 560 | return nil 561 | })) 562 | 563 | return nil 564 | } 565 | 566 | func (m *NotLoggingOneofMessage) MarshalLogObject(enc go_uber_org_zap_zapcore.ObjectEncoder) error { 567 | var keyName string 568 | _ = keyName 569 | 570 | keyName = "int32_value" // field int32_value = 1 571 | if ov, ok := m.GetOneofValue().(*NotLoggingOneofMessage_Int32Value); ok { 572 | _ = ov 573 | enc.AddInt32(keyName, ov.Int32Value) 574 | } 575 | 576 | keyName = "string_value" // field string_value = 2 577 | if ov, ok := m.GetOneofValue().(*NotLoggingOneofMessage_StringValue); ok { 578 | _ = ov 579 | enc.AddString(keyName, ov.StringValue) 580 | } 581 | 582 | keyName = "repeated_oneof_values" // field repeated_oneof_values = 3 583 | enc.AddArray(keyName, go_uber_org_zap_zapcore.ArrayMarshalerFunc(func(aenc go_uber_org_zap_zapcore.ArrayEncoder) error { 584 | for _, rv := range m.RepeatedOneofValues { 585 | _ = rv 586 | if rv != nil { 587 | var vv interface{} = rv 588 | if marshaler, ok := vv.(go_uber_org_zap_zapcore.ObjectMarshaler); ok { 589 | aenc.AppendObject(marshaler) 590 | } 591 | } 592 | } 593 | return nil 594 | })) 595 | 596 | return nil 597 | } 598 | 599 | func (m *MapMessage) MarshalLogObject(enc go_uber_org_zap_zapcore.ObjectEncoder) error { 600 | var keyName string 601 | _ = keyName 602 | 603 | keyName = "mapped_value" // field mapped_value = 1 604 | enc.AddObject(keyName, go_uber_org_zap_zapcore.ObjectMarshalerFunc(func(enc go_uber_org_zap_zapcore.ObjectEncoder) error { 605 | for mk, mv := range m.MappedValue { 606 | key := fmt.Sprint(mk) 607 | _ = key 608 | enc.AddString(key, mv) 609 | } 610 | return nil 611 | })) 612 | 613 | keyName = "mapped_enum_value" // field mapped_enum_value = 2 614 | enc.AddObject(keyName, go_uber_org_zap_zapcore.ObjectMarshalerFunc(func(enc go_uber_org_zap_zapcore.ObjectEncoder) error { 615 | for mk, mv := range m.MappedEnumValue { 616 | key := mk 617 | _ = key 618 | enc.AddString(key, mv.String()) 619 | } 620 | return nil 621 | })) 622 | 623 | keyName = "mapped_nested_value" // field mapped_nested_value = 3 624 | enc.AddObject(keyName, go_uber_org_zap_zapcore.ObjectMarshalerFunc(func(enc go_uber_org_zap_zapcore.ObjectEncoder) error { 625 | for mk, mv := range m.MappedNestedValue { 626 | key := mk 627 | _ = key 628 | if mv != nil { 629 | var vv interface{} = mv 630 | if marshaler, ok := vv.(go_uber_org_zap_zapcore.ObjectMarshaler); ok { 631 | enc.AddObject(key, marshaler) 632 | } 633 | } 634 | } 635 | return nil 636 | })) 637 | 638 | return nil 639 | } 640 | 641 | func (m *NotLoggingMapMessage) MarshalLogObject(enc go_uber_org_zap_zapcore.ObjectEncoder) error { 642 | var keyName string 643 | _ = keyName 644 | 645 | keyName = "mapped_value" // field mapped_value = 1 646 | enc.AddObject(keyName, go_uber_org_zap_zapcore.ObjectMarshalerFunc(func(enc go_uber_org_zap_zapcore.ObjectEncoder) error { 647 | for mk, mv := range m.MappedValue { 648 | key := fmt.Sprint(mk) 649 | _ = key 650 | enc.AddString(key, mv) 651 | } 652 | return nil 653 | })) 654 | 655 | keyName = "mapped_enum_value" // field mapped_enum_value = 2 656 | enc.AddObject(keyName, go_uber_org_zap_zapcore.ObjectMarshalerFunc(func(enc go_uber_org_zap_zapcore.ObjectEncoder) error { 657 | for mk, mv := range m.MappedEnumValue { 658 | key := mk 659 | _ = key 660 | enc.AddString(key, mv.String()) 661 | } 662 | return nil 663 | })) 664 | 665 | keyName = "mapped_nested_value" // field mapped_nested_value = 3 666 | enc.AddObject(keyName, go_uber_org_zap_zapcore.ObjectMarshalerFunc(func(enc go_uber_org_zap_zapcore.ObjectEncoder) error { 667 | for mk, mv := range m.MappedNestedValue { 668 | key := mk 669 | _ = key 670 | if mv != nil { 671 | var vv interface{} = mv 672 | if marshaler, ok := vv.(go_uber_org_zap_zapcore.ObjectMarshaler); ok { 673 | enc.AddObject(key, marshaler) 674 | } 675 | } 676 | } 677 | return nil 678 | })) 679 | 680 | return nil 681 | } 682 | 683 | func (m *JsonNameOptionMessage) MarshalLogObject(enc go_uber_org_zap_zapcore.ObjectEncoder) error { 684 | var keyName string 685 | _ = keyName 686 | 687 | keyName = "string_value" // field string_value = 1 688 | enc.AddString(keyName, m.StringValue) 689 | 690 | return nil 691 | } 692 | 693 | func (m *NotLoggingJsonNameOptionMessage) MarshalLogObject(enc go_uber_org_zap_zapcore.ObjectEncoder) error { 694 | var keyName string 695 | _ = keyName 696 | 697 | keyName = "string_value" // field string_value = 1 698 | enc.AddString(keyName, m.StringValue) 699 | 700 | return nil 701 | } 702 | 703 | func (m *WellKnownTypeMessage) MarshalLogObject(enc go_uber_org_zap_zapcore.ObjectEncoder) error { 704 | var keyName string 705 | _ = keyName 706 | 707 | keyName = "duration" // field duration = 1 708 | if d, err := github_com_golang_protobuf_ptypes.Duration(m.Duration); err == nil { 709 | enc.AddDuration(keyName, d) 710 | } 711 | 712 | keyName = "timestamp" // field timestamp = 2 713 | if t, err := github_com_golang_protobuf_ptypes.Timestamp(m.Timestamp); err == nil { 714 | enc.AddTime(keyName, t) 715 | } 716 | 717 | return nil 718 | } 719 | 720 | func (m *NotLoggingWellKnownTypeMessage) MarshalLogObject(enc go_uber_org_zap_zapcore.ObjectEncoder) error { 721 | var keyName string 722 | _ = keyName 723 | 724 | keyName = "duration" // field duration = 1 725 | if d, err := github_com_golang_protobuf_ptypes.Duration(m.Duration); err == nil { 726 | enc.AddDuration(keyName, d) 727 | } 728 | 729 | keyName = "timestamp" // field timestamp = 2 730 | if t, err := github_com_golang_protobuf_ptypes.Timestamp(m.Timestamp); err == nil { 731 | enc.AddTime(keyName, t) 732 | } 733 | 734 | return nil 735 | } 736 | 737 | func (m *MixedLoggingMessage) MarshalLogObject(enc go_uber_org_zap_zapcore.ObjectEncoder) error { 738 | var keyName string 739 | _ = keyName 740 | 741 | keyName = "string_value" // field string_value = 1 742 | enc.AddString(keyName, m.StringValue) 743 | 744 | keyName = "bool_value" // field bool_value = 2 745 | enc.AddBool(keyName, m.BoolValue) 746 | 747 | keyName = "int32_value" // field int32_value = 3 748 | enc.AddInt32(keyName, m.Int32Value) 749 | 750 | return nil 751 | } 752 | -------------------------------------------------------------------------------- /examples/zap-marshaler/example_test.go: -------------------------------------------------------------------------------- 1 | package examples 2 | 3 | import ( 4 | "time" 5 | 6 | "github.com/golang/protobuf/ptypes" 7 | "go.uber.org/zap" 8 | ) 9 | 10 | func ExampleTest() { 11 | l := zap.NewExample() 12 | l.Info("test", zap.Object("simple", &SimpleMessage{ 13 | StringValue: "xyz", 14 | BoolValue: true, 15 | })) 16 | // output: {"level":"info","msg":"test","simple":{"string_value":"xyz","bool_value":true}} 17 | } 18 | 19 | func ExampleNotLoggingTest() { 20 | l := zap.NewExample() 21 | l.Info("test", zap.Object("simple", &NotLoggingSimpleMessage{ 22 | StringValue: "xyz", 23 | BoolValue: true, 24 | })) 25 | // output: {"level":"info","msg":"test","simple":{"string_value":"xyz","bool_value":true}} 26 | } 27 | 28 | func ExampleNumberMessage() { 29 | l := zap.NewExample() 30 | l.Info("test", zap.Object("number", &NumberMessage{ 31 | FloatValue: 0.5, 32 | DoubleValue: 2.2, 33 | Int32Value: -3, 34 | Int64Value: -4, 35 | Uint32Value: 5, 36 | Uint64Value: 6, 37 | Sint32Value: -7, 38 | Sint64Value: -8, 39 | Fixed32Value: 9, 40 | Fixed64Value: 10, 41 | Sfixed32Value: -11, 42 | Sfixed64Value: -12, 43 | })) 44 | // output: {"level":"info","msg":"test","number":{"float_value":0.5,"double_value":2.2,"int32_value":-3,"int64_value":-4,"uint32_value":5,"uint64_value":6,"sint32_value":-7,"sint64_value":-8,"fixed32_value":9,"fixed64_value":10,"sfixed32_value":-11,"sfixed64_value":-12}} 45 | } 46 | 47 | func ExampleNotLoggingNumberMessage() { 48 | l := zap.NewExample() 49 | l.Info("test", zap.Object("number", &NotLoggingNumberMessage{ 50 | FloatValue: 0.5, 51 | DoubleValue: 2.2, 52 | Int32Value: -3, 53 | Int64Value: -4, 54 | Uint32Value: 5, 55 | Uint64Value: 6, 56 | Sint32Value: -7, 57 | Sint64Value: -8, 58 | Fixed32Value: 9, 59 | Fixed64Value: 10, 60 | Sfixed32Value: -11, 61 | Sfixed64Value: -12, 62 | })) 63 | // output: {"level":"info","msg":"test","number":{"float_value":0.5,"double_value":2.2,"int32_value":-3,"int64_value":-4,"uint32_value":5,"uint64_value":6,"sint32_value":-7,"sint64_value":-8,"fixed32_value":9,"fixed64_value":10,"sfixed32_value":-11,"sfixed64_value":-12}} 64 | } 65 | 66 | func ExampleRepeatedNumberMessage() { 67 | l := zap.NewExample() 68 | l.Info("test", zap.Object("number", &RepeatedNumberMessage{ 69 | FloatValues: []float32{0.5, 1}, 70 | DoubleValues: []float64{2.2, 1}, 71 | Int32Values: []int32{-3, 3}, 72 | Int64Values: []int64{-4, 4}, 73 | Uint32Values: []uint32{5, 55}, 74 | Uint64Values: []uint64{6, 66}, 75 | Sint32Values: []int32{-7, 7}, 76 | Sint64Values: []int64{-8, 8}, 77 | Fixed32Values: []uint32{9, 99}, 78 | Fixed64Values: []uint64{10, 100}, 79 | Sfixed32Values: []int32{-11, 11}, 80 | Sfixed64Values: []int64{-12, 12}, 81 | })) 82 | // output: {"level":"info","msg":"test","number":{"float_values":[0.5,1],"double_values":[2.2,1],"int32_values":[-3,3],"int64_values":[-4,4],"uint32_values":[5,55],"uint64_values":[6,66],"sint32_values":[-7,7],"sint64_values":[-8,8],"fixed32_values":[9,99],"fixed64_values":[10,100],"sfixed32_values":[-11,11],"sfixed64_values":[-12,12]}} 83 | } 84 | 85 | func ExampleNotLoggingRepeatedNumberMessage() { 86 | l := zap.NewExample() 87 | l.Info("test", zap.Object("number", &NotLoggingRepeatedNumberMessage{ 88 | FloatValues: []float32{0.5, 1}, 89 | DoubleValues: []float64{2.2, 1}, 90 | Int32Values: []int32{-3, 3}, 91 | Int64Values: []int64{-4, 4}, 92 | Uint32Values: []uint32{5, 55}, 93 | Uint64Values: []uint64{6, 66}, 94 | Sint32Values: []int32{-7, 7}, 95 | Sint64Values: []int64{-8, 8}, 96 | Fixed32Values: []uint32{9, 99}, 97 | Fixed64Values: []uint64{10, 100}, 98 | Sfixed32Values: []int32{-11, 11}, 99 | Sfixed64Values: []int64{-12, 12}, 100 | })) 101 | // output: {"level":"info","msg":"test","number":{"float_values":[0.5,1],"double_values":[2.2,1],"int32_values":[-3,3],"int64_values":[-4,4],"uint32_values":[5,55],"uint64_values":[6,66],"sint32_values":[-7,7],"sint64_values":[-8,8],"fixed32_values":[9,99],"fixed64_values":[10,100],"sfixed32_values":[-11,11],"sfixed64_values":[-12,12]}} 102 | } 103 | 104 | func ExampleNestedMessage() { 105 | l := zap.NewExample() 106 | l.Info("test", zap.Object("nested", &NestedMessage{ 107 | NestedValue: &NestedMessage_Nested{ 108 | Int32Value: 100, 109 | StringValue: "xxx", 110 | }, 111 | RepeatedNestedValues: []*NestedMessage_Nested{ 112 | { 113 | Int32Value: 200, 114 | StringValue: "yyy", 115 | }, 116 | { 117 | Int32Value: 300, 118 | StringValue: "zzz", 119 | }, 120 | }, 121 | })) 122 | // output: {"level":"info","msg":"test","nested":{"nested_value":{"int32_value":100,"string_value":"xxx"},"repeated_nested_values":[{"int32_value":200,"string_value":"yyy"},{"int32_value":300,"string_value":"zzz"}]}} 123 | } 124 | 125 | func ExampleNotLoggingNestedMessage() { 126 | l := zap.NewExample() 127 | l.Info("test", zap.Object("nested", &NotLoggingNestedMessage{ 128 | NestedValue: &NotLoggingNestedMessage_Nested{ 129 | Int32Value: 100, 130 | StringValue: "xxx", 131 | }, 132 | RepeatedNestedValues: []*NotLoggingNestedMessage_Nested{ 133 | { 134 | Int32Value: 200, 135 | StringValue: "yyy", 136 | }, 137 | { 138 | Int32Value: 300, 139 | StringValue: "zzz", 140 | }, 141 | }, 142 | })) 143 | // output: {"level":"info","msg":"test","nested":{"nested_value":{"int32_value":100,"string_value":"xxx"},"repeated_nested_values":[{"int32_value":200,"string_value":"yyy"},{"int32_value":300,"string_value":"zzz"}]}} 144 | } 145 | 146 | func ExampleEnumMessage() { 147 | l := zap.NewExample() 148 | l.Info("test", zap.Object("enum", &EnumMessage{ 149 | NumericEnumValue: NumericEnum_ONE, 150 | RepeatedNumericEnumValues: []NumericEnum{ 151 | NumericEnum_ONE, 152 | NumericEnum_TWO, 153 | }, 154 | AliasedEnumValue: AliasedEnum_RUNNING, 155 | NestedEnumValue: EnumMessage_PENDING, 156 | RepeatedNestedEnumValues: []EnumMessage_Nested{ 157 | EnumMessage_PENDING, 158 | EnumMessage_COMPLETED, 159 | }, 160 | })) 161 | // output: {"level":"info","msg":"test","enum":{"numeric_enum_value":"ONE","repeated_numeric_enum_values":["ONE","TWO"],"aliased_enum_value":"STARTED","nested_enum_value":"PENDING","repeated_nested_enum_values":["PENDING","COMPLETED"]}} 162 | } 163 | 164 | func ExampleNotLoggingEnumMessage() { 165 | l := zap.NewExample() 166 | l.Info("test", zap.Object("enum", &NotLoggingEnumMessage{ 167 | NumericEnumValue: NumericEnum_ONE, 168 | RepeatedNumericEnumValues: []NumericEnum{ 169 | NumericEnum_ONE, 170 | NumericEnum_TWO, 171 | }, 172 | AliasedEnumValue: AliasedEnum_RUNNING, 173 | NestedEnumValue: NotLoggingEnumMessage_PENDING, 174 | RepeatedNestedEnumValues: []NotLoggingEnumMessage_Nested{ 175 | NotLoggingEnumMessage_PENDING, 176 | NotLoggingEnumMessage_COMPLETED, 177 | }, 178 | })) 179 | // output: {"level":"info","msg":"test","enum":{"numeric_enum_value":"ONE","repeated_numeric_enum_values":["ONE","TWO"],"aliased_enum_value":"STARTED","nested_enum_value":"PENDING","repeated_nested_enum_values":["PENDING","COMPLETED"]}} 180 | } 181 | 182 | func ExampleOneofMessage() { 183 | l := zap.NewExample() 184 | l.Info("test", zap.Object("oneof", &OneofMessage{ 185 | OneofValue: &OneofMessage_Int32Value{Int32Value: 1000}, 186 | RepeatedOneofValues: []*Oneof{ 187 | { 188 | OneofValue: &Oneof_Int32Value{Int32Value: 1000}, 189 | }, 190 | { 191 | OneofValue: &Oneof_StringValue{StringValue: "xyz"}, 192 | }, 193 | }, 194 | })) 195 | // output: {"level":"info","msg":"test","oneof":{"int32_value":1000,"repeated_oneof_values":[{"int32_value":1000},{"string_value":"xyz"}]}} 196 | } 197 | 198 | func ExampleNotLoggingOneofMessage() { 199 | l := zap.NewExample() 200 | l.Info("test", zap.Object("oneof", &NotLoggingOneofMessage{ 201 | OneofValue: &NotLoggingOneofMessage_Int32Value{Int32Value: 1000}, 202 | RepeatedOneofValues: []*Oneof{ 203 | { 204 | OneofValue: &Oneof_Int32Value{Int32Value: 1000}, 205 | }, 206 | { 207 | OneofValue: &Oneof_StringValue{StringValue: "xyz"}, 208 | }, 209 | }, 210 | })) 211 | // output: {"level":"info","msg":"test","oneof":{"int32_value":1000,"repeated_oneof_values":[{"int32_value":1000},{"string_value":"xyz"}]}} 212 | } 213 | 214 | func ExampleMapMessage() { 215 | l := zap.NewExample() 216 | l.Info("test", zap.Object("map", &MapMessage{ 217 | MappedValue: map[int32]string{ 218 | 1: "foo", 219 | 2: "bar", 220 | }, 221 | MappedEnumValue: map[string]NumericEnum{ 222 | "one": NumericEnum_ONE, 223 | "two": NumericEnum_TWO, 224 | }, 225 | MappedNestedValue: map[string]*NestedMessage{ 226 | "foo": &NestedMessage{ 227 | NestedValue: &NestedMessage_Nested{ 228 | Int32Value: 100, 229 | StringValue: "xxx", 230 | }, 231 | RepeatedNestedValues: []*NestedMessage_Nested{ 232 | { 233 | Int32Value: 200, 234 | StringValue: "yyy", 235 | }, 236 | { 237 | Int32Value: 300, 238 | StringValue: "zzz", 239 | }, 240 | }, 241 | }, 242 | }, 243 | })) 244 | // output: {"level":"info","msg":"test","map":{"mapped_value":{"1":"foo","2":"bar"},"mapped_enum_value":{"one":"ONE","two":"TWO"},"mapped_nested_value":{"foo":{"nested_value":{"int32_value":100,"string_value":"xxx"},"repeated_nested_values":[{"int32_value":200,"string_value":"yyy"},{"int32_value":300,"string_value":"zzz"}]}}}} 245 | } 246 | 247 | func ExampleNotLoggingMapMessage() { 248 | l := zap.NewExample() 249 | l.Info("test", zap.Object("map", &NotLoggingMapMessage{ 250 | MappedValue: map[int32]string{ 251 | 1: "foo", 252 | 2: "bar", 253 | }, 254 | MappedEnumValue: map[string]NumericEnum{ 255 | "one": NumericEnum_ONE, 256 | "two": NumericEnum_TWO, 257 | }, 258 | MappedNestedValue: map[string]*NestedMessage{ 259 | "foo": &NestedMessage{ 260 | NestedValue: &NestedMessage_Nested{ 261 | Int32Value: 100, 262 | StringValue: "xxx", 263 | }, 264 | RepeatedNestedValues: []*NestedMessage_Nested{ 265 | { 266 | Int32Value: 200, 267 | StringValue: "yyy", 268 | }, 269 | { 270 | Int32Value: 300, 271 | StringValue: "zzz", 272 | }, 273 | }, 274 | }, 275 | }, 276 | })) 277 | // output: {"level":"info","msg":"test","map":{"mapped_value":{"1":"foo","2":"bar"},"mapped_enum_value":{"one":"ONE","two":"TWO"},"mapped_nested_value":{"foo":{"nested_value":{"int32_value":100,"string_value":"xxx"},"repeated_nested_values":[{"int32_value":200,"string_value":"yyy"},{"int32_value":300,"string_value":"zzz"}]}}}} 278 | } 279 | 280 | func ExampleJsonNameOptionMessage() { 281 | l := zap.NewExample() 282 | l.Info("test", zap.Object("json_name", &JsonNameOptionMessage{ 283 | StringValue: "xxx", 284 | })) 285 | // output: {"level":"info","msg":"test","json_name":{"string_value":"xxx"}} 286 | } 287 | 288 | func ExampleNotLoggingJsonNameOptionMessage() { 289 | l := zap.NewExample() 290 | l.Info("test", zap.Object("json_name", &NotLoggingJsonNameOptionMessage{ 291 | StringValue: "xxx", 292 | })) 293 | // output: {"level":"info","msg":"test","json_name":{"string_value":"xxx"}} 294 | } 295 | 296 | func ExampleWellKnownTypeMessage() { 297 | d := ptypes.DurationProto(10 * time.Minute) 298 | t, _ := ptypes.TimestampProto(time.Unix(1502533013, 125892275)) 299 | l := zap.NewExample() 300 | l.Info("test", zap.Object("wkt", &WellKnownTypeMessage{ 301 | Duration: d, 302 | Timestamp: t, 303 | })) 304 | // output: {"level":"info","msg":"test","wkt":{"duration":"10m0s","timestamp":"2017-08-12T10:16:53.125Z"}} 305 | } 306 | 307 | func ExampleNotLoggingWellKnownTypeMessage() { 308 | d := ptypes.DurationProto(10 * time.Minute) 309 | t, _ := ptypes.TimestampProto(time.Unix(1502533013, 125892275)) 310 | l := zap.NewExample() 311 | l.Info("test", zap.Object("wkt", &NotLoggingWellKnownTypeMessage{ 312 | Duration: d, 313 | Timestamp: t, 314 | })) 315 | // output: {"level":"info","msg":"test","wkt":{"duration":"10m0s","timestamp":"2017-08-12T10:16:53.125Z"}} 316 | } 317 | 318 | func ExampleMixedLoggingMessage() { 319 | l := zap.NewExample() 320 | l.Info("test", zap.Object("mlm", &MixedLoggingMessage{ 321 | StringValue: "xxx", 322 | BoolValue: true, 323 | Int32Value: 1, 324 | })) 325 | // {"level":"info","msg":"test","mlm":{"string_value":"xxx","bool_value":true,"int32_value":1}} 326 | } 327 | 328 | func ExampleTestWithNilField() { 329 | l := zap.NewExample() 330 | sl := l.Sugar() 331 | var sm *SimpleMessage = nil 332 | sl = sl.With("SimpleMessage", sm) 333 | sl.Infow("test") 334 | // output: {"level":"info","msg":"test","SimpleMessage":{}} 335 | } 336 | -------------------------------------------------------------------------------- /plugin/plugin.go: -------------------------------------------------------------------------------- 1 | package plugin 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/gogo/protobuf/gogoproto" 7 | "github.com/gogo/protobuf/proto" 8 | "github.com/gogo/protobuf/protoc-gen-gogo/descriptor" 9 | "github.com/gogo/protobuf/protoc-gen-gogo/generator" 10 | zap_marshaler "github.com/kazegusuri/go-proto-zap-marshaler" 11 | ) 12 | 13 | type plugin struct { 14 | *generator.Generator 15 | generator.PluginImports 16 | zapcore generator.Single 17 | ptypes generator.Single 18 | 19 | secure bool 20 | } 21 | 22 | // NewPlugin creates a plugin for protoc. 23 | // 24 | // If secure is true, the plugin respects the zap_marshaler option 25 | // for fields to be marshaled by zap. 26 | func NewPlugin(secure bool) generator.Plugin { 27 | return &plugin{secure: secure} 28 | } 29 | 30 | func (p *plugin) Name() string { 31 | return "zap-marshaler" 32 | } 33 | 34 | func (p *plugin) Init(g *generator.Generator) { 35 | p.Generator = g 36 | } 37 | 38 | func (p *plugin) Generate(file *generator.FileDescriptor) { 39 | p.PluginImports = generator.NewPluginImports(p.Generator) 40 | p.zapcore = p.NewImport("go.uber.org/zap/zapcore") 41 | p.ptypes = p.NewImport("github.com/golang/protobuf/ptypes") 42 | 43 | for _, msg := range file.Messages() { 44 | if msg.DescriptorProto.GetOptions().GetMapEntry() { 45 | continue 46 | } 47 | 48 | if gogoproto.IsProto3(file.FileDescriptorProto) { 49 | p.generateProto3Message(file, msg) 50 | } 51 | } 52 | } 53 | 54 | func isTarget(d *descriptor.FieldDescriptorProto) bool { 55 | if d.GetOptions() == nil { 56 | return false 57 | } 58 | ext, err := proto.GetExtension(d.Options, zap_marshaler.E_Field) 59 | if err != nil { 60 | return false 61 | } 62 | 63 | rule, ok := ext.(*zap_marshaler.ZapMarshalerRule) 64 | return ok && rule.Enabled 65 | } 66 | 67 | func (p *plugin) generateProto3Message(file *generator.FileDescriptor, message *generator.Descriptor) { 68 | typeName := generator.CamelCaseSlice(message.TypeName()) 69 | p.P(`func (m *`, typeName, `) MarshalLogObject(enc `, p.zapcore.Use(), `.ObjectEncoder) error {`) 70 | p.In() 71 | p.P("var keyName string") 72 | p.P("_ = keyName") 73 | p.P("") 74 | p.P("if m == nil {") 75 | p.P("return nil") 76 | p.P("}") 77 | p.P("") 78 | 79 | for _, field := range message.Field { 80 | // see the field option only when secure option is true. 81 | if p.secure && !isTarget(field) { 82 | continue 83 | } 84 | 85 | fieldName := p.GetOneOfFieldName(message, field) 86 | jsonName := field.GetName() 87 | variableName := "m." + fieldName 88 | p.P(`keyName = "`, jsonName, `" // field `, field.GetName(), " = ", fmt.Sprint(field.GetNumber())) 89 | 90 | repeated := field.IsRepeated() && !p.IsMap(field) 91 | if repeated { 92 | p.P(`enc.AddArray(keyName, `, p.zapcore.Use(), `.ArrayMarshalerFunc(func(aenc `, p.zapcore.Use(), `.ArrayEncoder) error {`) 93 | p.In() 94 | 95 | p.P(`for _, rv := range `, variableName, `{`) 96 | variableName = "rv" 97 | p.In() 98 | p.P(`_ = `, variableName) // suppress unused error 99 | } 100 | 101 | if p.isOneofType(field) { 102 | oneofName := p.GetFieldName(message, field) 103 | oneofType := p.OneOfTypeName(message, field) 104 | p.P(`if ov, ok := m`, `.Get`, oneofName+`().(* `+oneofType+`); ok {`) 105 | variableName = "ov." + fieldName 106 | p.In() 107 | p.P(` _ = ov`) 108 | } 109 | 110 | p.generateForField(file, message, field, "keyName", variableName, repeated) 111 | 112 | if p.isOneofType(field) { 113 | p.Out() 114 | p.P(`}`) 115 | } 116 | 117 | if repeated { 118 | p.Out() 119 | p.P(`}`) 120 | 121 | p.P(`return nil`) 122 | p.Out() 123 | p.P(`}))`) 124 | } 125 | 126 | p.P() 127 | } 128 | p.P(`return nil`) 129 | p.Out() 130 | p.P(`}`) 131 | p.P() 132 | } 133 | 134 | func (p *plugin) isOneofType(field *descriptor.FieldDescriptorProto) bool { 135 | return field.OneofIndex != nil 136 | } 137 | 138 | func (p *plugin) generateForField(file *generator.FileDescriptor, message *generator.Descriptor, field *descriptor.FieldDescriptorProto, keyName, variableName string, repeated bool) { 139 | // TODO: support well known type to log pretty message 140 | // TODO: marshal unknown type 141 | 142 | switch field.GetTypeName() { 143 | case ".google.protobuf.Duration": 144 | p.P(`if d, err := `, p.ptypes.Use(), ".Duration(", variableName, "); err == nil {") 145 | p.In() 146 | p.generateAdder("Duration", keyName, "d", repeated) 147 | p.Out() 148 | p.P(`}`) 149 | return 150 | 151 | case ".google.protobuf.Timestamp": 152 | p.P(`if t, err := `, p.ptypes.Use(), ".Timestamp(", variableName, "); err == nil {") 153 | p.In() 154 | p.generateAdder("Time", keyName, "t", repeated) 155 | p.Out() 156 | p.P(`}`) 157 | return 158 | } 159 | 160 | if p.IsMap(field) { 161 | mapDesc := p.GoMapType(nil, field) 162 | if mapDesc == nil { 163 | p.P("// unavaiable map type") 164 | return 165 | } 166 | keyField := mapDesc.KeyField 167 | valField := mapDesc.ValueField 168 | 169 | // sanity check to avoid unexpected loop 170 | if p.IsMap(valField) { 171 | p.P("// unavaible map type: nested map") 172 | return 173 | } 174 | 175 | p.P(`enc.AddObject(keyName, `, p.zapcore.Use(), `.ObjectMarshalerFunc(func(enc `, p.zapcore.Use(), `.ObjectEncoder) error {`) 176 | p.In() 177 | 178 | p.P("for mk, mv := range ", variableName, " {") 179 | p.In() 180 | if keyField.IsString() { 181 | p.P("key := mk") 182 | } else { 183 | p.P("key := fmt.Sprint(mk)") 184 | } 185 | p.P(" _ = key") 186 | p.generateForField(file, message, valField, "key", "mv", false) 187 | 188 | p.Out() 189 | p.P("}") 190 | 191 | p.P(`return nil`) 192 | p.Out() 193 | p.P(`}))`) 194 | 195 | return 196 | } 197 | 198 | switch *(field.Type) { 199 | case descriptor.FieldDescriptorProto_TYPE_INT32: 200 | p.generateAdder("Int32", keyName, variableName, repeated) 201 | case descriptor.FieldDescriptorProto_TYPE_INT64: 202 | p.generateAdder("Int64", keyName, variableName, repeated) 203 | case descriptor.FieldDescriptorProto_TYPE_UINT32: 204 | p.generateAdder("Uint32", keyName, variableName, repeated) 205 | case descriptor.FieldDescriptorProto_TYPE_UINT64: 206 | p.generateAdder("Uint64", keyName, variableName, repeated) 207 | case descriptor.FieldDescriptorProto_TYPE_SINT32: 208 | p.generateAdder("Int32", keyName, variableName, repeated) 209 | case descriptor.FieldDescriptorProto_TYPE_SINT64: 210 | p.generateAdder("Int64", keyName, variableName, repeated) 211 | case descriptor.FieldDescriptorProto_TYPE_FIXED32: 212 | p.generateAdder("Uint32", keyName, variableName, repeated) 213 | case descriptor.FieldDescriptorProto_TYPE_FIXED64: 214 | p.generateAdder("Uint64", keyName, variableName, repeated) 215 | case descriptor.FieldDescriptorProto_TYPE_SFIXED32: 216 | p.generateAdder("Int32", keyName, variableName, repeated) 217 | case descriptor.FieldDescriptorProto_TYPE_SFIXED64: 218 | p.generateAdder("Int64", keyName, variableName, repeated) 219 | case descriptor.FieldDescriptorProto_TYPE_FLOAT: 220 | p.generateAdder("Float32", keyName, variableName, repeated) 221 | case descriptor.FieldDescriptorProto_TYPE_DOUBLE: 222 | p.generateAdder("Float64", keyName, variableName, repeated) 223 | 224 | case descriptor.FieldDescriptorProto_TYPE_BOOL: 225 | p.generateAdder("Bool", keyName, variableName, repeated) 226 | case descriptor.FieldDescriptorProto_TYPE_STRING: 227 | p.generateAdder("String", keyName, variableName, repeated) 228 | case descriptor.FieldDescriptorProto_TYPE_BYTES: 229 | p.generateAdder("ByteString", keyName, variableName, repeated) 230 | 231 | case descriptor.FieldDescriptorProto_TYPE_ENUM: 232 | if repeated { 233 | p.P(`aenc.AppendString(`, variableName, `.String())`) 234 | } else { 235 | p.P(`enc.AddString(`, keyName, `, `, variableName, `.String())`) 236 | } 237 | 238 | case descriptor.FieldDescriptorProto_TYPE_MESSAGE: 239 | p.P(`if `, variableName, ` != nil {`) 240 | p.In() 241 | 242 | p.P(`var vv interface{} = `, variableName) 243 | p.P(`if marshaler, ok := `, `vv.(`, p.zapcore.Use(), `.ObjectMarshaler); ok {`) 244 | p.In() 245 | p.generateAdder("Object", keyName, "marshaler", repeated) 246 | p.Out() 247 | p.P(`}`) 248 | 249 | p.Out() 250 | p.P(`}`) 251 | 252 | case descriptor.FieldDescriptorProto_TYPE_GROUP: 253 | // ? 254 | p.P("// group type not supported") 255 | } 256 | } 257 | 258 | func (p *plugin) generateAdder(ftype, keyName, variable string, repeated bool) { 259 | if repeated { 260 | p.P("aenc.Append", ftype, "(", variable, ")") 261 | } else { 262 | p.P("enc.Add", ftype, `(`, keyName, `, `, variable, `)`) 263 | } 264 | } 265 | -------------------------------------------------------------------------------- /protoc-gen-zap-marshaler-secure/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "io/ioutil" 5 | "os" 6 | "strings" 7 | 8 | "github.com/gogo/protobuf/proto" 9 | "github.com/gogo/protobuf/protoc-gen-gogo/generator" 10 | "github.com/kazegusuri/go-proto-zap-marshaler/plugin" 11 | ) 12 | 13 | func main() { 14 | gen := generator.New() 15 | 16 | data, err := ioutil.ReadAll(os.Stdin) 17 | if err != nil { 18 | gen.Error(err, "reading input") 19 | } 20 | 21 | if err := proto.Unmarshal(data, gen.Request); err != nil { 22 | gen.Error(err, "parsing input proto") 23 | } 24 | 25 | if len(gen.Request.FileToGenerate) == 0 { 26 | gen.Fail("no files to generate") 27 | } 28 | 29 | gen.CommandLineParameters(gen.Request.GetParameter()) 30 | gen.WrapTypes() 31 | gen.SetPackageNames() 32 | gen.BuildTypeNameMap() 33 | gen.GeneratePlugin(plugin.NewPlugin(true)) 34 | 35 | for i := range gen.Response.File { 36 | gen.Response.File[i].Name = proto.String(strings.Replace(*gen.Response.File[i].Name, ".pb.go", ".zap.go", -1)) 37 | gen.Response.File[i].Content = proto.String(strings.Replace(*gen.Response.File[i].Content, `"github.com/gogo/protobuf/proto"`, `"github.com/golang/protobuf/proto"`, -1)) 38 | } 39 | 40 | data, err = proto.Marshal(gen.Response) 41 | if err != nil { 42 | gen.Error(err, "failed to marshal output proto") 43 | } 44 | if _, err = os.Stdout.Write(data); err != nil { 45 | gen.Error(err, "failed to write output proto") 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /protoc-gen-zap-marshaler/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "io/ioutil" 5 | "os" 6 | "strings" 7 | 8 | "github.com/gogo/protobuf/proto" 9 | "github.com/gogo/protobuf/protoc-gen-gogo/generator" 10 | "github.com/kazegusuri/go-proto-zap-marshaler/plugin" 11 | ) 12 | 13 | func main() { 14 | gen := generator.New() 15 | 16 | data, err := ioutil.ReadAll(os.Stdin) 17 | if err != nil { 18 | gen.Error(err, "reading input") 19 | } 20 | 21 | if err := proto.Unmarshal(data, gen.Request); err != nil { 22 | gen.Error(err, "parsing input proto") 23 | } 24 | 25 | if len(gen.Request.FileToGenerate) == 0 { 26 | gen.Fail("no files to generate") 27 | } 28 | 29 | gen.CommandLineParameters(gen.Request.GetParameter()) 30 | gen.WrapTypes() 31 | gen.SetPackageNames() 32 | gen.BuildTypeNameMap() 33 | gen.GeneratePlugin(plugin.NewPlugin(false)) 34 | 35 | for i := range gen.Response.File { 36 | gen.Response.File[i].Name = proto.String(strings.Replace(*gen.Response.File[i].Name, ".pb.go", ".zap.go", -1)) 37 | gen.Response.File[i].Content = proto.String(strings.Replace(*gen.Response.File[i].Content, `"github.com/gogo/protobuf/proto"`, `"github.com/golang/protobuf/proto"`, -1)) 38 | } 39 | 40 | data, err = proto.Marshal(gen.Response) 41 | if err != nil { 42 | gen.Error(err, "failed to marshal output proto") 43 | } 44 | if _, err = os.Stdout.Write(data); err != nil { 45 | gen.Error(err, "failed to write output proto") 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /zap_marshaler.pb.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoc-gen-gogo. DO NOT EDIT. 2 | // source: zap_marshaler.proto 3 | 4 | package zap_marshaler // import "github.com/kazegusuri/go-proto-zap-marshaler" 5 | 6 | import proto "github.com/gogo/protobuf/proto" 7 | import fmt "fmt" 8 | import math "math" 9 | import descriptor "github.com/gogo/protobuf/protoc-gen-gogo/descriptor" 10 | 11 | // Reference imports to suppress errors if they are not otherwise used. 12 | var _ = proto.Marshal 13 | var _ = fmt.Errorf 14 | var _ = math.Inf 15 | 16 | // This is a compile-time assertion to ensure that this generated file 17 | // is compatible with the proto package it is being compiled against. 18 | // A compilation error at this line likely means your copy of the 19 | // proto package needs to be updated. 20 | const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package 21 | 22 | type ZapMarshalerRule struct { 23 | Enabled bool `protobuf:"varint,1,opt,name=enabled,proto3" json:"enabled,omitempty"` 24 | XXX_NoUnkeyedLiteral struct{} `json:"-"` 25 | XXX_unrecognized []byte `json:"-"` 26 | XXX_sizecache int32 `json:"-"` 27 | } 28 | 29 | func (m *ZapMarshalerRule) Reset() { *m = ZapMarshalerRule{} } 30 | func (m *ZapMarshalerRule) String() string { return proto.CompactTextString(m) } 31 | func (*ZapMarshalerRule) ProtoMessage() {} 32 | func (*ZapMarshalerRule) Descriptor() ([]byte, []int) { 33 | return fileDescriptor_zap_marshaler_e0b1c9cd6a84cae1, []int{0} 34 | } 35 | func (m *ZapMarshalerRule) XXX_Unmarshal(b []byte) error { 36 | return xxx_messageInfo_ZapMarshalerRule.Unmarshal(m, b) 37 | } 38 | func (m *ZapMarshalerRule) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { 39 | return xxx_messageInfo_ZapMarshalerRule.Marshal(b, m, deterministic) 40 | } 41 | func (dst *ZapMarshalerRule) XXX_Merge(src proto.Message) { 42 | xxx_messageInfo_ZapMarshalerRule.Merge(dst, src) 43 | } 44 | func (m *ZapMarshalerRule) XXX_Size() int { 45 | return xxx_messageInfo_ZapMarshalerRule.Size(m) 46 | } 47 | func (m *ZapMarshalerRule) XXX_DiscardUnknown() { 48 | xxx_messageInfo_ZapMarshalerRule.DiscardUnknown(m) 49 | } 50 | 51 | var xxx_messageInfo_ZapMarshalerRule proto.InternalMessageInfo 52 | 53 | func (m *ZapMarshalerRule) GetEnabled() bool { 54 | if m != nil { 55 | return m.Enabled 56 | } 57 | return false 58 | } 59 | 60 | var E_Field = &proto.ExtensionDesc{ 61 | ExtendedType: (*descriptor.FieldOptions)(nil), 62 | ExtensionType: (*ZapMarshalerRule)(nil), 63 | Field: 64553, 64 | Name: "kazegusuri.zap_mashaler.field", 65 | Tag: "bytes,64553,opt,name=field", 66 | Filename: "zap_marshaler.proto", 67 | } 68 | 69 | func init() { 70 | proto.RegisterType((*ZapMarshalerRule)(nil), "kazegusuri.zap_mashaler.ZapMarshalerRule") 71 | proto.RegisterExtension(E_Field) 72 | } 73 | 74 | func init() { proto.RegisterFile("zap_marshaler.proto", fileDescriptor_zap_marshaler_e0b1c9cd6a84cae1) } 75 | 76 | var fileDescriptor_zap_marshaler_e0b1c9cd6a84cae1 = []byte{ 77 | // 209 bytes of a gzipped FileDescriptorProto 78 | 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0xae, 0x4a, 0x2c, 0x88, 79 | 0xcf, 0x4d, 0x2c, 0x2a, 0xce, 0x48, 0xcc, 0x49, 0x2d, 0xd2, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 80 | 0x12, 0xcf, 0x4e, 0xac, 0x4a, 0x4d, 0x2f, 0x2d, 0x2e, 0x2d, 0xca, 0xd4, 0x83, 0xc8, 0x43, 0xa4, 81 | 0xa5, 0x14, 0xd2, 0xf3, 0xf3, 0xd3, 0x73, 0x52, 0xf5, 0xc1, 0xca, 0x92, 0x4a, 0xd3, 0xf4, 0x53, 82 | 0x52, 0x8b, 0x93, 0x8b, 0x32, 0x0b, 0x4a, 0xf2, 0xa1, 0x5a, 0x95, 0x74, 0xb8, 0x04, 0xa2, 0x12, 83 | 0x0b, 0x7c, 0x61, 0x06, 0x06, 0x95, 0xe6, 0xa4, 0x0a, 0x49, 0x70, 0xb1, 0xa7, 0xe6, 0x25, 0x26, 84 | 0xe5, 0xa4, 0xa6, 0x48, 0x30, 0x2a, 0x30, 0x6a, 0x70, 0x04, 0xc1, 0xb8, 0x56, 0x09, 0x5c, 0xac, 85 | 0x69, 0x99, 0xa9, 0x39, 0x29, 0x42, 0xb2, 0x7a, 0x10, 0x93, 0xf5, 0x60, 0x26, 0xeb, 0xb9, 0x81, 86 | 0xc4, 0xfd, 0x0b, 0x4a, 0x32, 0xf3, 0xf3, 0x8a, 0x25, 0x56, 0xfe, 0x60, 0x56, 0x60, 0xd4, 0xe0, 87 | 0x36, 0xd2, 0xd4, 0xc3, 0xe1, 0x32, 0x3d, 0x74, 0x4b, 0x83, 0x20, 0x06, 0x3b, 0xd9, 0x44, 0x59, 88 | 0xa5, 0x67, 0x96, 0x64, 0x94, 0x26, 0xe9, 0x25, 0xe7, 0xe7, 0xea, 0x23, 0x74, 0xeb, 0xa7, 0xe7, 89 | 0xeb, 0x82, 0xed, 0xd2, 0xad, 0x4a, 0x2c, 0xd0, 0x85, 0x07, 0x80, 0x35, 0x4a, 0x70, 0x24, 0xb1, 90 | 0x81, 0x95, 0x18, 0x03, 0x02, 0x00, 0x00, 0xff, 0xff, 0x15, 0xe9, 0x41, 0xb1, 0x26, 0x01, 0x00, 91 | 0x00, 92 | } 93 | -------------------------------------------------------------------------------- /zap_marshaler.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package kazegusuri.zap_mashaler; 4 | 5 | import "google/protobuf/descriptor.proto"; 6 | option go_package = "github.com/kazegusuri/go-proto-zap-marshaler;zap_marshaler"; 7 | 8 | extend google.protobuf.FieldOptions { 9 | ZapMarshalerRule field = 64553; 10 | } 11 | 12 | message ZapMarshalerRule { 13 | bool enabled = 1; 14 | } 15 | --------------------------------------------------------------------------------