planetscale 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.github/workflows/ci.yml +24 -0
- data/.github/workflows/gem-push.yml +38 -0
- data/.github/workflows/licensed.yml +43 -0
- data/.gitignore +10 -0
- data/.licensed.yml +9 -0
- data/.licenses/go/github.com/armon/circbuf.dep.yml +31 -0
- data/.licenses/go/github.com/gorilla/mux.dep.yml +41 -0
- data/.licenses/go/github.com/hashicorp/go-cleanhttp.dep.yml +375 -0
- data/.licenses/go/github.com/mitchellh/go-homedir.dep.yml +32 -0
- data/.licenses/go/github.com/pkg/errors.dep.yml +36 -0
- data/.licenses/go/github.com/planetscale/planetscale-go/planetscale.dep.yml +160 -0
- data/.licenses/go/github.com/planetscale/sql-proxy/proxy.dep.yml +180 -0
- data/.licenses/go/go.uber.org/atomic.dep.yml +31 -0
- data/.licenses/go/go.uber.org/multierr.dep.yml +30 -0
- data/.licenses/go/go.uber.org/zap.dep.yml +30 -0
- data/.licenses/go/go.uber.org/zap/buffer.dep.yml +30 -0
- data/.licenses/go/go.uber.org/zap/internal/bufferpool.dep.yml +30 -0
- data/.licenses/go/go.uber.org/zap/internal/color.dep.yml +30 -0
- data/.licenses/go/go.uber.org/zap/internal/exit.dep.yml +31 -0
- data/.licenses/go/go.uber.org/zap/zapcore.dep.yml +31 -0
- data/.licenses/go/golang.org/x/net/context/ctxhttp.dep.yml +63 -0
- data/.licenses/go/golang.org/x/oauth2.dep.yml +44 -0
- data/.licenses/go/golang.org/x/oauth2/internal.dep.yml +38 -0
- data/.ruby_version +1 -0
- data/Gemfile +8 -0
- data/LICENSE +201 -0
- data/README.md +88 -0
- data/Rakefile +10 -0
- data/bin/console +15 -0
- data/bin/setup +17 -0
- data/controller.go +255 -0
- data/go.mod +16 -0
- data/go.sum +428 -0
- data/lib/generators/planetscale/install_generator.rb +58 -0
- data/lib/planetscale.rb +137 -0
- data/lib/planetscale/version.rb +5 -0
- data/planetscale.gemspec +44 -0
- data/proxy.go +128 -0
- data/vendor/github.com/armon/circbuf/.gitignore +22 -0
- data/vendor/github.com/armon/circbuf/LICENSE +20 -0
- data/vendor/github.com/armon/circbuf/README.md +28 -0
- data/vendor/github.com/armon/circbuf/circbuf.go +92 -0
- data/vendor/github.com/armon/circbuf/go.mod +1 -0
- data/vendor/github.com/golang/protobuf/AUTHORS +3 -0
- data/vendor/github.com/golang/protobuf/CONTRIBUTORS +3 -0
- data/vendor/github.com/golang/protobuf/LICENSE +28 -0
- data/vendor/github.com/golang/protobuf/proto/buffer.go +324 -0
- data/vendor/github.com/golang/protobuf/proto/defaults.go +63 -0
- data/vendor/github.com/golang/protobuf/proto/deprecated.go +113 -0
- data/vendor/github.com/golang/protobuf/proto/discard.go +58 -0
- data/vendor/github.com/golang/protobuf/proto/extensions.go +356 -0
- data/vendor/github.com/golang/protobuf/proto/properties.go +306 -0
- data/vendor/github.com/golang/protobuf/proto/proto.go +167 -0
- data/vendor/github.com/golang/protobuf/proto/registry.go +317 -0
- data/vendor/github.com/golang/protobuf/proto/text_decode.go +801 -0
- data/vendor/github.com/golang/protobuf/proto/text_encode.go +560 -0
- data/vendor/github.com/golang/protobuf/proto/wire.go +78 -0
- data/vendor/github.com/golang/protobuf/proto/wrappers.go +34 -0
- data/vendor/github.com/gorilla/mux/AUTHORS +8 -0
- data/vendor/github.com/gorilla/mux/LICENSE +27 -0
- data/vendor/github.com/gorilla/mux/README.md +805 -0
- data/vendor/github.com/gorilla/mux/doc.go +306 -0
- data/vendor/github.com/gorilla/mux/go.mod +3 -0
- data/vendor/github.com/gorilla/mux/middleware.go +74 -0
- data/vendor/github.com/gorilla/mux/mux.go +606 -0
- data/vendor/github.com/gorilla/mux/regexp.go +388 -0
- data/vendor/github.com/gorilla/mux/route.go +736 -0
- data/vendor/github.com/gorilla/mux/test_helpers.go +19 -0
- data/vendor/github.com/hashicorp/go-cleanhttp/LICENSE +363 -0
- data/vendor/github.com/hashicorp/go-cleanhttp/README.md +30 -0
- data/vendor/github.com/hashicorp/go-cleanhttp/cleanhttp.go +58 -0
- data/vendor/github.com/hashicorp/go-cleanhttp/doc.go +20 -0
- data/vendor/github.com/hashicorp/go-cleanhttp/go.mod +3 -0
- data/vendor/github.com/hashicorp/go-cleanhttp/handlers.go +48 -0
- data/vendor/github.com/mitchellh/go-homedir/LICENSE +21 -0
- data/vendor/github.com/mitchellh/go-homedir/README.md +14 -0
- data/vendor/github.com/mitchellh/go-homedir/go.mod +1 -0
- data/vendor/github.com/mitchellh/go-homedir/homedir.go +167 -0
- data/vendor/github.com/pkg/errors/.gitignore +24 -0
- data/vendor/github.com/pkg/errors/.travis.yml +10 -0
- data/vendor/github.com/pkg/errors/LICENSE +23 -0
- data/vendor/github.com/pkg/errors/Makefile +44 -0
- data/vendor/github.com/pkg/errors/README.md +59 -0
- data/vendor/github.com/pkg/errors/appveyor.yml +32 -0
- data/vendor/github.com/pkg/errors/errors.go +288 -0
- data/vendor/github.com/pkg/errors/go113.go +38 -0
- data/vendor/github.com/pkg/errors/stack.go +177 -0
- data/vendor/github.com/planetscale/planetscale-go/planetscale/backups.go +139 -0
- data/vendor/github.com/planetscale/planetscale-go/planetscale/branches.go +258 -0
- data/vendor/github.com/planetscale/planetscale-go/planetscale/certs.go +142 -0
- data/vendor/github.com/planetscale/planetscale-go/planetscale/client.go +305 -0
- data/vendor/github.com/planetscale/planetscale-go/planetscale/databases.go +131 -0
- data/vendor/github.com/planetscale/planetscale-go/planetscale/deploy_requests.go +368 -0
- data/vendor/github.com/planetscale/planetscale-go/planetscale/organizations.go +78 -0
- data/vendor/github.com/planetscale/planetscale-go/planetscale/service_tokens.go +163 -0
- data/vendor/github.com/planetscale/sql-proxy/proxy/client.go +467 -0
- data/vendor/github.com/planetscale/sql-proxy/proxy/tls_cache.go +73 -0
- data/vendor/go.uber.org/atomic/.codecov.yml +19 -0
- data/vendor/go.uber.org/atomic/.gitignore +12 -0
- data/vendor/go.uber.org/atomic/.travis.yml +27 -0
- data/vendor/go.uber.org/atomic/CHANGELOG.md +76 -0
- data/vendor/go.uber.org/atomic/LICENSE.txt +19 -0
- data/vendor/go.uber.org/atomic/Makefile +78 -0
- data/vendor/go.uber.org/atomic/README.md +63 -0
- data/vendor/go.uber.org/atomic/bool.go +81 -0
- data/vendor/go.uber.org/atomic/bool_ext.go +53 -0
- data/vendor/go.uber.org/atomic/doc.go +23 -0
- data/vendor/go.uber.org/atomic/duration.go +82 -0
- data/vendor/go.uber.org/atomic/duration_ext.go +40 -0
- data/vendor/go.uber.org/atomic/error.go +51 -0
- data/vendor/go.uber.org/atomic/error_ext.go +39 -0
- data/vendor/go.uber.org/atomic/float64.go +76 -0
- data/vendor/go.uber.org/atomic/float64_ext.go +47 -0
- data/vendor/go.uber.org/atomic/gen.go +26 -0
- data/vendor/go.uber.org/atomic/go.mod +8 -0
- data/vendor/go.uber.org/atomic/go.sum +9 -0
- data/vendor/go.uber.org/atomic/int32.go +102 -0
- data/vendor/go.uber.org/atomic/int64.go +102 -0
- data/vendor/go.uber.org/atomic/nocmp.go +35 -0
- data/vendor/go.uber.org/atomic/string.go +54 -0
- data/vendor/go.uber.org/atomic/string_ext.go +43 -0
- data/vendor/go.uber.org/atomic/uint32.go +102 -0
- data/vendor/go.uber.org/atomic/uint64.go +102 -0
- data/vendor/go.uber.org/atomic/value.go +31 -0
- data/vendor/go.uber.org/multierr/.codecov.yml +15 -0
- data/vendor/go.uber.org/multierr/.gitignore +4 -0
- data/vendor/go.uber.org/multierr/.travis.yml +23 -0
- data/vendor/go.uber.org/multierr/CHANGELOG.md +60 -0
- data/vendor/go.uber.org/multierr/LICENSE.txt +19 -0
- data/vendor/go.uber.org/multierr/Makefile +42 -0
- data/vendor/go.uber.org/multierr/README.md +23 -0
- data/vendor/go.uber.org/multierr/error.go +449 -0
- data/vendor/go.uber.org/multierr/glide.yaml +8 -0
- data/vendor/go.uber.org/multierr/go.mod +8 -0
- data/vendor/go.uber.org/multierr/go.sum +11 -0
- data/vendor/go.uber.org/multierr/go113.go +52 -0
- data/vendor/go.uber.org/zap/.codecov.yml +17 -0
- data/vendor/go.uber.org/zap/.gitignore +32 -0
- data/vendor/go.uber.org/zap/.readme.tmpl +109 -0
- data/vendor/go.uber.org/zap/.travis.yml +23 -0
- data/vendor/go.uber.org/zap/CHANGELOG.md +432 -0
- data/vendor/go.uber.org/zap/CODE_OF_CONDUCT.md +75 -0
- data/vendor/go.uber.org/zap/CONTRIBUTING.md +81 -0
- data/vendor/go.uber.org/zap/FAQ.md +156 -0
- data/vendor/go.uber.org/zap/LICENSE.txt +19 -0
- data/vendor/go.uber.org/zap/Makefile +63 -0
- data/vendor/go.uber.org/zap/README.md +134 -0
- data/vendor/go.uber.org/zap/array.go +320 -0
- data/vendor/go.uber.org/zap/buffer/buffer.go +123 -0
- data/vendor/go.uber.org/zap/buffer/pool.go +49 -0
- data/vendor/go.uber.org/zap/checklicense.sh +17 -0
- data/vendor/go.uber.org/zap/config.go +264 -0
- data/vendor/go.uber.org/zap/doc.go +113 -0
- data/vendor/go.uber.org/zap/encoder.go +79 -0
- data/vendor/go.uber.org/zap/error.go +80 -0
- data/vendor/go.uber.org/zap/field.go +539 -0
- data/vendor/go.uber.org/zap/flag.go +39 -0
- data/vendor/go.uber.org/zap/glide.yaml +34 -0
- data/vendor/go.uber.org/zap/global.go +168 -0
- data/vendor/go.uber.org/zap/global_go112.go +26 -0
- data/vendor/go.uber.org/zap/global_prego112.go +26 -0
- data/vendor/go.uber.org/zap/go.mod +13 -0
- data/vendor/go.uber.org/zap/go.sum +56 -0
- data/vendor/go.uber.org/zap/http_handler.go +81 -0
- data/vendor/go.uber.org/zap/internal/bufferpool/bufferpool.go +31 -0
- data/vendor/go.uber.org/zap/internal/color/color.go +44 -0
- data/vendor/go.uber.org/zap/internal/exit/exit.go +64 -0
- data/vendor/go.uber.org/zap/level.go +132 -0
- data/vendor/go.uber.org/zap/logger.go +344 -0
- data/vendor/go.uber.org/zap/options.go +140 -0
- data/vendor/go.uber.org/zap/sink.go +161 -0
- data/vendor/go.uber.org/zap/stacktrace.go +85 -0
- data/vendor/go.uber.org/zap/sugar.go +304 -0
- data/vendor/go.uber.org/zap/time.go +27 -0
- data/vendor/go.uber.org/zap/writer.go +99 -0
- data/vendor/go.uber.org/zap/zapcore/console_encoder.go +161 -0
- data/vendor/go.uber.org/zap/zapcore/core.go +113 -0
- data/vendor/go.uber.org/zap/zapcore/doc.go +24 -0
- data/vendor/go.uber.org/zap/zapcore/encoder.go +443 -0
- data/vendor/go.uber.org/zap/zapcore/entry.go +264 -0
- data/vendor/go.uber.org/zap/zapcore/error.go +115 -0
- data/vendor/go.uber.org/zap/zapcore/field.go +227 -0
- data/vendor/go.uber.org/zap/zapcore/hook.go +68 -0
- data/vendor/go.uber.org/zap/zapcore/increase_level.go +66 -0
- data/vendor/go.uber.org/zap/zapcore/json_encoder.go +534 -0
- data/vendor/go.uber.org/zap/zapcore/level.go +175 -0
- data/vendor/go.uber.org/zap/zapcore/level_strings.go +46 -0
- data/vendor/go.uber.org/zap/zapcore/marshaler.go +61 -0
- data/vendor/go.uber.org/zap/zapcore/memory_encoder.go +179 -0
- data/vendor/go.uber.org/zap/zapcore/sampler.go +208 -0
- data/vendor/go.uber.org/zap/zapcore/tee.go +81 -0
- data/vendor/go.uber.org/zap/zapcore/write_syncer.go +123 -0
- data/vendor/golang.org/x/net/AUTHORS +3 -0
- data/vendor/golang.org/x/net/CONTRIBUTORS +3 -0
- data/vendor/golang.org/x/net/LICENSE +27 -0
- data/vendor/golang.org/x/net/PATENTS +22 -0
- data/vendor/golang.org/x/net/context/context.go +56 -0
- data/vendor/golang.org/x/net/context/ctxhttp/ctxhttp.go +71 -0
- data/vendor/golang.org/x/net/context/go17.go +73 -0
- data/vendor/golang.org/x/net/context/go19.go +21 -0
- data/vendor/golang.org/x/net/context/pre_go17.go +301 -0
- data/vendor/golang.org/x/net/context/pre_go19.go +110 -0
- data/vendor/golang.org/x/oauth2/.travis.yml +13 -0
- data/vendor/golang.org/x/oauth2/AUTHORS +3 -0
- data/vendor/golang.org/x/oauth2/CONTRIBUTING.md +26 -0
- data/vendor/golang.org/x/oauth2/CONTRIBUTORS +3 -0
- data/vendor/golang.org/x/oauth2/LICENSE +27 -0
- data/vendor/golang.org/x/oauth2/README.md +36 -0
- data/vendor/golang.org/x/oauth2/go.mod +9 -0
- data/vendor/golang.org/x/oauth2/go.sum +361 -0
- data/vendor/golang.org/x/oauth2/internal/client_appengine.go +14 -0
- data/vendor/golang.org/x/oauth2/internal/doc.go +6 -0
- data/vendor/golang.org/x/oauth2/internal/oauth2.go +37 -0
- data/vendor/golang.org/x/oauth2/internal/token.go +294 -0
- data/vendor/golang.org/x/oauth2/internal/transport.go +33 -0
- data/vendor/golang.org/x/oauth2/oauth2.go +381 -0
- data/vendor/golang.org/x/oauth2/token.go +178 -0
- data/vendor/golang.org/x/oauth2/transport.go +89 -0
- data/vendor/google.golang.org/appengine/LICENSE +202 -0
- data/vendor/google.golang.org/appengine/internal/api.go +678 -0
- data/vendor/google.golang.org/appengine/internal/api_classic.go +169 -0
- data/vendor/google.golang.org/appengine/internal/api_common.go +123 -0
- data/vendor/google.golang.org/appengine/internal/app_id.go +28 -0
- data/vendor/google.golang.org/appengine/internal/base/api_base.pb.go +308 -0
- data/vendor/google.golang.org/appengine/internal/base/api_base.proto +33 -0
- data/vendor/google.golang.org/appengine/internal/datastore/datastore_v3.pb.go +4367 -0
- data/vendor/google.golang.org/appengine/internal/datastore/datastore_v3.proto +551 -0
- data/vendor/google.golang.org/appengine/internal/identity.go +55 -0
- data/vendor/google.golang.org/appengine/internal/identity_classic.go +61 -0
- data/vendor/google.golang.org/appengine/internal/identity_flex.go +11 -0
- data/vendor/google.golang.org/appengine/internal/identity_vm.go +134 -0
- data/vendor/google.golang.org/appengine/internal/internal.go +110 -0
- data/vendor/google.golang.org/appengine/internal/log/log_service.pb.go +1313 -0
- data/vendor/google.golang.org/appengine/internal/log/log_service.proto +150 -0
- data/vendor/google.golang.org/appengine/internal/main.go +16 -0
- data/vendor/google.golang.org/appengine/internal/main_common.go +7 -0
- data/vendor/google.golang.org/appengine/internal/main_vm.go +69 -0
- data/vendor/google.golang.org/appengine/internal/metadata.go +60 -0
- data/vendor/google.golang.org/appengine/internal/net.go +56 -0
- data/vendor/google.golang.org/appengine/internal/regen.sh +40 -0
- data/vendor/google.golang.org/appengine/internal/remote_api/remote_api.pb.go +361 -0
- data/vendor/google.golang.org/appengine/internal/remote_api/remote_api.proto +44 -0
- data/vendor/google.golang.org/appengine/internal/transaction.go +115 -0
- data/vendor/google.golang.org/appengine/internal/urlfetch/urlfetch_service.pb.go +527 -0
- data/vendor/google.golang.org/appengine/internal/urlfetch/urlfetch_service.proto +64 -0
- data/vendor/google.golang.org/appengine/urlfetch/urlfetch.go +210 -0
- data/vendor/google.golang.org/protobuf/AUTHORS +3 -0
- data/vendor/google.golang.org/protobuf/CONTRIBUTORS +3 -0
- data/vendor/google.golang.org/protobuf/LICENSE +27 -0
- data/vendor/google.golang.org/protobuf/PATENTS +22 -0
- data/vendor/google.golang.org/protobuf/encoding/prototext/decode.go +773 -0
- data/vendor/google.golang.org/protobuf/encoding/prototext/doc.go +7 -0
- data/vendor/google.golang.org/protobuf/encoding/prototext/encode.go +371 -0
- data/vendor/google.golang.org/protobuf/encoding/protowire/wire.go +538 -0
- data/vendor/google.golang.org/protobuf/internal/descfmt/stringer.go +318 -0
- data/vendor/google.golang.org/protobuf/internal/descopts/options.go +29 -0
- data/vendor/google.golang.org/protobuf/internal/detrand/rand.go +69 -0
- data/vendor/google.golang.org/protobuf/internal/encoding/defval/default.go +213 -0
- data/vendor/google.golang.org/protobuf/internal/encoding/messageset/messageset.go +241 -0
- data/vendor/google.golang.org/protobuf/internal/encoding/tag/tag.go +207 -0
- data/vendor/google.golang.org/protobuf/internal/encoding/text/decode.go +665 -0
- data/vendor/google.golang.org/protobuf/internal/encoding/text/decode_number.go +190 -0
- data/vendor/google.golang.org/protobuf/internal/encoding/text/decode_string.go +161 -0
- data/vendor/google.golang.org/protobuf/internal/encoding/text/decode_token.go +373 -0
- data/vendor/google.golang.org/protobuf/internal/encoding/text/doc.go +29 -0
- data/vendor/google.golang.org/protobuf/internal/encoding/text/encode.go +265 -0
- data/vendor/google.golang.org/protobuf/internal/errors/errors.go +89 -0
- data/vendor/google.golang.org/protobuf/internal/errors/is_go112.go +39 -0
- data/vendor/google.golang.org/protobuf/internal/errors/is_go113.go +12 -0
- data/vendor/google.golang.org/protobuf/internal/filedesc/build.go +158 -0
- data/vendor/google.golang.org/protobuf/internal/filedesc/desc.go +631 -0
- data/vendor/google.golang.org/protobuf/internal/filedesc/desc_init.go +471 -0
- data/vendor/google.golang.org/protobuf/internal/filedesc/desc_lazy.go +704 -0
- data/vendor/google.golang.org/protobuf/internal/filedesc/desc_list.go +450 -0
- data/vendor/google.golang.org/protobuf/internal/filedesc/desc_list_gen.go +356 -0
- data/vendor/google.golang.org/protobuf/internal/filedesc/placeholder.go +107 -0
- data/vendor/google.golang.org/protobuf/internal/filetype/build.go +297 -0
- data/vendor/google.golang.org/protobuf/internal/flags/flags.go +24 -0
- data/vendor/google.golang.org/protobuf/internal/flags/proto_legacy_disable.go +9 -0
- data/vendor/google.golang.org/protobuf/internal/flags/proto_legacy_enable.go +9 -0
- data/vendor/google.golang.org/protobuf/internal/genid/any_gen.go +34 -0
- data/vendor/google.golang.org/protobuf/internal/genid/api_gen.go +106 -0
- data/vendor/google.golang.org/protobuf/internal/genid/descriptor_gen.go +829 -0
- data/vendor/google.golang.org/protobuf/internal/genid/doc.go +11 -0
- data/vendor/google.golang.org/protobuf/internal/genid/duration_gen.go +34 -0
- data/vendor/google.golang.org/protobuf/internal/genid/empty_gen.go +19 -0
- data/vendor/google.golang.org/protobuf/internal/genid/field_mask_gen.go +31 -0
- data/vendor/google.golang.org/protobuf/internal/genid/goname.go +25 -0
- data/vendor/google.golang.org/protobuf/internal/genid/map_entry.go +16 -0
- data/vendor/google.golang.org/protobuf/internal/genid/source_context_gen.go +31 -0
- data/vendor/google.golang.org/protobuf/internal/genid/struct_gen.go +116 -0
- data/vendor/google.golang.org/protobuf/internal/genid/timestamp_gen.go +34 -0
- data/vendor/google.golang.org/protobuf/internal/genid/type_gen.go +184 -0
- data/vendor/google.golang.org/protobuf/internal/genid/wrappers.go +13 -0
- data/vendor/google.golang.org/protobuf/internal/genid/wrappers_gen.go +175 -0
- data/vendor/google.golang.org/protobuf/internal/impl/api_export.go +177 -0
- data/vendor/google.golang.org/protobuf/internal/impl/checkinit.go +141 -0
- data/vendor/google.golang.org/protobuf/internal/impl/codec_extension.go +223 -0
- data/vendor/google.golang.org/protobuf/internal/impl/codec_field.go +830 -0
- data/vendor/google.golang.org/protobuf/internal/impl/codec_gen.go +5637 -0
- data/vendor/google.golang.org/protobuf/internal/impl/codec_map.go +388 -0
- data/vendor/google.golang.org/protobuf/internal/impl/codec_map_go111.go +37 -0
- data/vendor/google.golang.org/protobuf/internal/impl/codec_map_go112.go +11 -0
- data/vendor/google.golang.org/protobuf/internal/impl/codec_message.go +217 -0
- data/vendor/google.golang.org/protobuf/internal/impl/codec_messageset.go +123 -0
- data/vendor/google.golang.org/protobuf/internal/impl/codec_reflect.go +209 -0
- data/vendor/google.golang.org/protobuf/internal/impl/codec_tables.go +557 -0
- data/vendor/google.golang.org/protobuf/internal/impl/codec_unsafe.go +17 -0
- data/vendor/google.golang.org/protobuf/internal/impl/convert.go +496 -0
- data/vendor/google.golang.org/protobuf/internal/impl/convert_list.go +141 -0
- data/vendor/google.golang.org/protobuf/internal/impl/convert_map.go +121 -0
- data/vendor/google.golang.org/protobuf/internal/impl/decode.go +276 -0
- data/vendor/google.golang.org/protobuf/internal/impl/encode.go +201 -0
- data/vendor/google.golang.org/protobuf/internal/impl/enum.go +21 -0
- data/vendor/google.golang.org/protobuf/internal/impl/extension.go +156 -0
- data/vendor/google.golang.org/protobuf/internal/impl/legacy_enum.go +219 -0
- data/vendor/google.golang.org/protobuf/internal/impl/legacy_export.go +92 -0
- data/vendor/google.golang.org/protobuf/internal/impl/legacy_extension.go +176 -0
- data/vendor/google.golang.org/protobuf/internal/impl/legacy_file.go +81 -0
- data/vendor/google.golang.org/protobuf/internal/impl/legacy_message.go +558 -0
- data/vendor/google.golang.org/protobuf/internal/impl/merge.go +176 -0
- data/vendor/google.golang.org/protobuf/internal/impl/merge_gen.go +209 -0
- data/vendor/google.golang.org/protobuf/internal/impl/message.go +276 -0
- data/vendor/google.golang.org/protobuf/internal/impl/message_reflect.go +465 -0
- data/vendor/google.golang.org/protobuf/internal/impl/message_reflect_field.go +543 -0
- data/vendor/google.golang.org/protobuf/internal/impl/message_reflect_gen.go +249 -0
- data/vendor/google.golang.org/protobuf/internal/impl/pointer_reflect.go +178 -0
- data/vendor/google.golang.org/protobuf/internal/impl/pointer_unsafe.go +174 -0
- data/vendor/google.golang.org/protobuf/internal/impl/validate.go +576 -0
- data/vendor/google.golang.org/protobuf/internal/impl/weak.go +74 -0
- data/vendor/google.golang.org/protobuf/internal/order/order.go +89 -0
- data/vendor/google.golang.org/protobuf/internal/order/range.go +115 -0
- data/vendor/google.golang.org/protobuf/internal/pragma/pragma.go +29 -0
- data/vendor/google.golang.org/protobuf/internal/set/ints.go +58 -0
- data/vendor/google.golang.org/protobuf/internal/strs/strings.go +196 -0
- data/vendor/google.golang.org/protobuf/internal/strs/strings_pure.go +27 -0
- data/vendor/google.golang.org/protobuf/internal/strs/strings_unsafe.go +94 -0
- data/vendor/google.golang.org/protobuf/internal/version/version.go +79 -0
- data/vendor/google.golang.org/protobuf/proto/checkinit.go +71 -0
- data/vendor/google.golang.org/protobuf/proto/decode.go +278 -0
- data/vendor/google.golang.org/protobuf/proto/decode_gen.go +603 -0
- data/vendor/google.golang.org/protobuf/proto/doc.go +94 -0
- data/vendor/google.golang.org/protobuf/proto/encode.go +319 -0
- data/vendor/google.golang.org/protobuf/proto/encode_gen.go +97 -0
- data/vendor/google.golang.org/protobuf/proto/equal.go +167 -0
- data/vendor/google.golang.org/protobuf/proto/extension.go +92 -0
- data/vendor/google.golang.org/protobuf/proto/merge.go +139 -0
- data/vendor/google.golang.org/protobuf/proto/messageset.go +93 -0
- data/vendor/google.golang.org/protobuf/proto/proto.go +43 -0
- data/vendor/google.golang.org/protobuf/proto/proto_methods.go +19 -0
- data/vendor/google.golang.org/protobuf/proto/proto_reflect.go +19 -0
- data/vendor/google.golang.org/protobuf/proto/reset.go +43 -0
- data/vendor/google.golang.org/protobuf/proto/size.go +97 -0
- data/vendor/google.golang.org/protobuf/proto/size_gen.go +55 -0
- data/vendor/google.golang.org/protobuf/proto/wrappers.go +29 -0
- data/vendor/google.golang.org/protobuf/reflect/protodesc/desc.go +276 -0
- data/vendor/google.golang.org/protobuf/reflect/protodesc/desc_init.go +248 -0
- data/vendor/google.golang.org/protobuf/reflect/protodesc/desc_resolve.go +286 -0
- data/vendor/google.golang.org/protobuf/reflect/protodesc/desc_validate.go +374 -0
- data/vendor/google.golang.org/protobuf/reflect/protodesc/proto.go +252 -0
- data/vendor/google.golang.org/protobuf/reflect/protoreflect/methods.go +77 -0
- data/vendor/google.golang.org/protobuf/reflect/protoreflect/proto.go +504 -0
- data/vendor/google.golang.org/protobuf/reflect/protoreflect/source.go +128 -0
- data/vendor/google.golang.org/protobuf/reflect/protoreflect/source_gen.go +461 -0
- data/vendor/google.golang.org/protobuf/reflect/protoreflect/type.go +665 -0
- data/vendor/google.golang.org/protobuf/reflect/protoreflect/value.go +285 -0
- data/vendor/google.golang.org/protobuf/reflect/protoreflect/value_pure.go +59 -0
- data/vendor/google.golang.org/protobuf/reflect/protoreflect/value_union.go +411 -0
- data/vendor/google.golang.org/protobuf/reflect/protoreflect/value_unsafe.go +98 -0
- data/vendor/google.golang.org/protobuf/reflect/protoregistry/registry.go +869 -0
- data/vendor/google.golang.org/protobuf/runtime/protoiface/legacy.go +15 -0
- data/vendor/google.golang.org/protobuf/runtime/protoiface/methods.go +167 -0
- data/vendor/google.golang.org/protobuf/runtime/protoimpl/impl.go +44 -0
- data/vendor/google.golang.org/protobuf/runtime/protoimpl/version.go +56 -0
- data/vendor/google.golang.org/protobuf/types/descriptorpb/descriptor.pb.go +4039 -0
- data/vendor/modules.txt +79 -0
- metadata +495 -0
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
// Copyright (c) 2016 Uber Technologies, Inc.
|
|
2
|
+
//
|
|
3
|
+
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
+
// of this software and associated documentation files (the "Software"), to deal
|
|
5
|
+
// in the Software without restriction, including without limitation the rights
|
|
6
|
+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
+
// copies of the Software, and to permit persons to whom the Software is
|
|
8
|
+
// furnished to do so, subject to the following conditions:
|
|
9
|
+
//
|
|
10
|
+
// The above copyright notice and this permission notice shall be included in
|
|
11
|
+
// all copies or substantial portions of the Software.
|
|
12
|
+
//
|
|
13
|
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
19
|
+
// THE SOFTWARE.
|
|
20
|
+
|
|
21
|
+
package zapcore
|
|
22
|
+
|
|
23
|
+
import (
|
|
24
|
+
"fmt"
|
|
25
|
+
"runtime"
|
|
26
|
+
"strings"
|
|
27
|
+
"sync"
|
|
28
|
+
"time"
|
|
29
|
+
|
|
30
|
+
"go.uber.org/zap/internal/bufferpool"
|
|
31
|
+
"go.uber.org/zap/internal/exit"
|
|
32
|
+
|
|
33
|
+
"go.uber.org/multierr"
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
var (
|
|
37
|
+
_cePool = sync.Pool{New: func() interface{} {
|
|
38
|
+
// Pre-allocate some space for cores.
|
|
39
|
+
return &CheckedEntry{
|
|
40
|
+
cores: make([]Core, 4),
|
|
41
|
+
}
|
|
42
|
+
}}
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
func getCheckedEntry() *CheckedEntry {
|
|
46
|
+
ce := _cePool.Get().(*CheckedEntry)
|
|
47
|
+
ce.reset()
|
|
48
|
+
return ce
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
func putCheckedEntry(ce *CheckedEntry) {
|
|
52
|
+
if ce == nil {
|
|
53
|
+
return
|
|
54
|
+
}
|
|
55
|
+
_cePool.Put(ce)
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// NewEntryCaller makes an EntryCaller from the return signature of
|
|
59
|
+
// runtime.Caller.
|
|
60
|
+
func NewEntryCaller(pc uintptr, file string, line int, ok bool) EntryCaller {
|
|
61
|
+
if !ok {
|
|
62
|
+
return EntryCaller{}
|
|
63
|
+
}
|
|
64
|
+
return EntryCaller{
|
|
65
|
+
PC: pc,
|
|
66
|
+
File: file,
|
|
67
|
+
Line: line,
|
|
68
|
+
Defined: true,
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// EntryCaller represents the caller of a logging function.
|
|
73
|
+
type EntryCaller struct {
|
|
74
|
+
Defined bool
|
|
75
|
+
PC uintptr
|
|
76
|
+
File string
|
|
77
|
+
Line int
|
|
78
|
+
Function string
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// String returns the full path and line number of the caller.
|
|
82
|
+
func (ec EntryCaller) String() string {
|
|
83
|
+
return ec.FullPath()
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// FullPath returns a /full/path/to/package/file:line description of the
|
|
87
|
+
// caller.
|
|
88
|
+
func (ec EntryCaller) FullPath() string {
|
|
89
|
+
if !ec.Defined {
|
|
90
|
+
return "undefined"
|
|
91
|
+
}
|
|
92
|
+
buf := bufferpool.Get()
|
|
93
|
+
buf.AppendString(ec.File)
|
|
94
|
+
buf.AppendByte(':')
|
|
95
|
+
buf.AppendInt(int64(ec.Line))
|
|
96
|
+
caller := buf.String()
|
|
97
|
+
buf.Free()
|
|
98
|
+
return caller
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// TrimmedPath returns a package/file:line description of the caller,
|
|
102
|
+
// preserving only the leaf directory name and file name.
|
|
103
|
+
func (ec EntryCaller) TrimmedPath() string {
|
|
104
|
+
if !ec.Defined {
|
|
105
|
+
return "undefined"
|
|
106
|
+
}
|
|
107
|
+
// nb. To make sure we trim the path correctly on Windows too, we
|
|
108
|
+
// counter-intuitively need to use '/' and *not* os.PathSeparator here,
|
|
109
|
+
// because the path given originates from Go stdlib, specifically
|
|
110
|
+
// runtime.Caller() which (as of Mar/17) returns forward slashes even on
|
|
111
|
+
// Windows.
|
|
112
|
+
//
|
|
113
|
+
// See https://github.com/golang/go/issues/3335
|
|
114
|
+
// and https://github.com/golang/go/issues/18151
|
|
115
|
+
//
|
|
116
|
+
// for discussion on the issue on Go side.
|
|
117
|
+
//
|
|
118
|
+
// Find the last separator.
|
|
119
|
+
//
|
|
120
|
+
idx := strings.LastIndexByte(ec.File, '/')
|
|
121
|
+
if idx == -1 {
|
|
122
|
+
return ec.FullPath()
|
|
123
|
+
}
|
|
124
|
+
// Find the penultimate separator.
|
|
125
|
+
idx = strings.LastIndexByte(ec.File[:idx], '/')
|
|
126
|
+
if idx == -1 {
|
|
127
|
+
return ec.FullPath()
|
|
128
|
+
}
|
|
129
|
+
buf := bufferpool.Get()
|
|
130
|
+
// Keep everything after the penultimate separator.
|
|
131
|
+
buf.AppendString(ec.File[idx+1:])
|
|
132
|
+
buf.AppendByte(':')
|
|
133
|
+
buf.AppendInt(int64(ec.Line))
|
|
134
|
+
caller := buf.String()
|
|
135
|
+
buf.Free()
|
|
136
|
+
return caller
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// An Entry represents a complete log message. The entry's structured context
|
|
140
|
+
// is already serialized, but the log level, time, message, and call site
|
|
141
|
+
// information are available for inspection and modification. Any fields left
|
|
142
|
+
// empty will be omitted when encoding.
|
|
143
|
+
//
|
|
144
|
+
// Entries are pooled, so any functions that accept them MUST be careful not to
|
|
145
|
+
// retain references to them.
|
|
146
|
+
type Entry struct {
|
|
147
|
+
Level Level
|
|
148
|
+
Time time.Time
|
|
149
|
+
LoggerName string
|
|
150
|
+
Message string
|
|
151
|
+
Caller EntryCaller
|
|
152
|
+
Stack string
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// CheckWriteAction indicates what action to take after a log entry is
|
|
156
|
+
// processed. Actions are ordered in increasing severity.
|
|
157
|
+
type CheckWriteAction uint8
|
|
158
|
+
|
|
159
|
+
const (
|
|
160
|
+
// WriteThenNoop indicates that nothing special needs to be done. It's the
|
|
161
|
+
// default behavior.
|
|
162
|
+
WriteThenNoop CheckWriteAction = iota
|
|
163
|
+
// WriteThenGoexit runs runtime.Goexit after Write.
|
|
164
|
+
WriteThenGoexit
|
|
165
|
+
// WriteThenPanic causes a panic after Write.
|
|
166
|
+
WriteThenPanic
|
|
167
|
+
// WriteThenFatal causes a fatal os.Exit after Write.
|
|
168
|
+
WriteThenFatal
|
|
169
|
+
)
|
|
170
|
+
|
|
171
|
+
// CheckedEntry is an Entry together with a collection of Cores that have
|
|
172
|
+
// already agreed to log it.
|
|
173
|
+
//
|
|
174
|
+
// CheckedEntry references should be created by calling AddCore or Should on a
|
|
175
|
+
// nil *CheckedEntry. References are returned to a pool after Write, and MUST
|
|
176
|
+
// NOT be retained after calling their Write method.
|
|
177
|
+
type CheckedEntry struct {
|
|
178
|
+
Entry
|
|
179
|
+
ErrorOutput WriteSyncer
|
|
180
|
+
dirty bool // best-effort detection of pool misuse
|
|
181
|
+
should CheckWriteAction
|
|
182
|
+
cores []Core
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
func (ce *CheckedEntry) reset() {
|
|
186
|
+
ce.Entry = Entry{}
|
|
187
|
+
ce.ErrorOutput = nil
|
|
188
|
+
ce.dirty = false
|
|
189
|
+
ce.should = WriteThenNoop
|
|
190
|
+
for i := range ce.cores {
|
|
191
|
+
// don't keep references to cores
|
|
192
|
+
ce.cores[i] = nil
|
|
193
|
+
}
|
|
194
|
+
ce.cores = ce.cores[:0]
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
// Write writes the entry to the stored Cores, returns any errors, and returns
|
|
198
|
+
// the CheckedEntry reference to a pool for immediate re-use. Finally, it
|
|
199
|
+
// executes any required CheckWriteAction.
|
|
200
|
+
func (ce *CheckedEntry) Write(fields ...Field) {
|
|
201
|
+
if ce == nil {
|
|
202
|
+
return
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
if ce.dirty {
|
|
206
|
+
if ce.ErrorOutput != nil {
|
|
207
|
+
// Make a best effort to detect unsafe re-use of this CheckedEntry.
|
|
208
|
+
// If the entry is dirty, log an internal error; because the
|
|
209
|
+
// CheckedEntry is being used after it was returned to the pool,
|
|
210
|
+
// the message may be an amalgamation from multiple call sites.
|
|
211
|
+
fmt.Fprintf(ce.ErrorOutput, "%v Unsafe CheckedEntry re-use near Entry %+v.\n", time.Now(), ce.Entry)
|
|
212
|
+
ce.ErrorOutput.Sync()
|
|
213
|
+
}
|
|
214
|
+
return
|
|
215
|
+
}
|
|
216
|
+
ce.dirty = true
|
|
217
|
+
|
|
218
|
+
var err error
|
|
219
|
+
for i := range ce.cores {
|
|
220
|
+
err = multierr.Append(err, ce.cores[i].Write(ce.Entry, fields))
|
|
221
|
+
}
|
|
222
|
+
if ce.ErrorOutput != nil {
|
|
223
|
+
if err != nil {
|
|
224
|
+
fmt.Fprintf(ce.ErrorOutput, "%v write error: %v\n", time.Now(), err)
|
|
225
|
+
ce.ErrorOutput.Sync()
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
should, msg := ce.should, ce.Message
|
|
230
|
+
putCheckedEntry(ce)
|
|
231
|
+
|
|
232
|
+
switch should {
|
|
233
|
+
case WriteThenPanic:
|
|
234
|
+
panic(msg)
|
|
235
|
+
case WriteThenFatal:
|
|
236
|
+
exit.Exit()
|
|
237
|
+
case WriteThenGoexit:
|
|
238
|
+
runtime.Goexit()
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
// AddCore adds a Core that has agreed to log this CheckedEntry. It's intended to be
|
|
243
|
+
// used by Core.Check implementations, and is safe to call on nil CheckedEntry
|
|
244
|
+
// references.
|
|
245
|
+
func (ce *CheckedEntry) AddCore(ent Entry, core Core) *CheckedEntry {
|
|
246
|
+
if ce == nil {
|
|
247
|
+
ce = getCheckedEntry()
|
|
248
|
+
ce.Entry = ent
|
|
249
|
+
}
|
|
250
|
+
ce.cores = append(ce.cores, core)
|
|
251
|
+
return ce
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
// Should sets this CheckedEntry's CheckWriteAction, which controls whether a
|
|
255
|
+
// Core will panic or fatal after writing this log entry. Like AddCore, it's
|
|
256
|
+
// safe to call on nil CheckedEntry references.
|
|
257
|
+
func (ce *CheckedEntry) Should(ent Entry, should CheckWriteAction) *CheckedEntry {
|
|
258
|
+
if ce == nil {
|
|
259
|
+
ce = getCheckedEntry()
|
|
260
|
+
ce.Entry = ent
|
|
261
|
+
}
|
|
262
|
+
ce.should = should
|
|
263
|
+
return ce
|
|
264
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
// Copyright (c) 2017 Uber Technologies, Inc.
|
|
2
|
+
//
|
|
3
|
+
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
+
// of this software and associated documentation files (the "Software"), to deal
|
|
5
|
+
// in the Software without restriction, including without limitation the rights
|
|
6
|
+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
+
// copies of the Software, and to permit persons to whom the Software is
|
|
8
|
+
// furnished to do so, subject to the following conditions:
|
|
9
|
+
//
|
|
10
|
+
// The above copyright notice and this permission notice shall be included in
|
|
11
|
+
// all copies or substantial portions of the Software.
|
|
12
|
+
//
|
|
13
|
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
19
|
+
// THE SOFTWARE.
|
|
20
|
+
|
|
21
|
+
package zapcore
|
|
22
|
+
|
|
23
|
+
import (
|
|
24
|
+
"fmt"
|
|
25
|
+
"sync"
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
// Encodes the given error into fields of an object. A field with the given
|
|
29
|
+
// name is added for the error message.
|
|
30
|
+
//
|
|
31
|
+
// If the error implements fmt.Formatter, a field with the name ${key}Verbose
|
|
32
|
+
// is also added with the full verbose error message.
|
|
33
|
+
//
|
|
34
|
+
// Finally, if the error implements errorGroup (from go.uber.org/multierr) or
|
|
35
|
+
// causer (from github.com/pkg/errors), a ${key}Causes field is added with an
|
|
36
|
+
// array of objects containing the errors this error was comprised of.
|
|
37
|
+
//
|
|
38
|
+
// {
|
|
39
|
+
// "error": err.Error(),
|
|
40
|
+
// "errorVerbose": fmt.Sprintf("%+v", err),
|
|
41
|
+
// "errorCauses": [
|
|
42
|
+
// ...
|
|
43
|
+
// ],
|
|
44
|
+
// }
|
|
45
|
+
func encodeError(key string, err error, enc ObjectEncoder) error {
|
|
46
|
+
basic := err.Error()
|
|
47
|
+
enc.AddString(key, basic)
|
|
48
|
+
|
|
49
|
+
switch e := err.(type) {
|
|
50
|
+
case errorGroup:
|
|
51
|
+
return enc.AddArray(key+"Causes", errArray(e.Errors()))
|
|
52
|
+
case fmt.Formatter:
|
|
53
|
+
verbose := fmt.Sprintf("%+v", e)
|
|
54
|
+
if verbose != basic {
|
|
55
|
+
// This is a rich error type, like those produced by
|
|
56
|
+
// github.com/pkg/errors.
|
|
57
|
+
enc.AddString(key+"Verbose", verbose)
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return nil
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
type errorGroup interface {
|
|
64
|
+
// Provides read-only access to the underlying list of errors, preferably
|
|
65
|
+
// without causing any allocs.
|
|
66
|
+
Errors() []error
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// Note that errArry and errArrayElem are very similar to the version
|
|
70
|
+
// implemented in the top-level error.go file. We can't re-use this because
|
|
71
|
+
// that would require exporting errArray as part of the zapcore API.
|
|
72
|
+
|
|
73
|
+
// Encodes a list of errors using the standard error encoding logic.
|
|
74
|
+
type errArray []error
|
|
75
|
+
|
|
76
|
+
func (errs errArray) MarshalLogArray(arr ArrayEncoder) error {
|
|
77
|
+
for i := range errs {
|
|
78
|
+
if errs[i] == nil {
|
|
79
|
+
continue
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
el := newErrArrayElem(errs[i])
|
|
83
|
+
arr.AppendObject(el)
|
|
84
|
+
el.Free()
|
|
85
|
+
}
|
|
86
|
+
return nil
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
var _errArrayElemPool = sync.Pool{New: func() interface{} {
|
|
90
|
+
return &errArrayElem{}
|
|
91
|
+
}}
|
|
92
|
+
|
|
93
|
+
// Encodes any error into a {"error": ...} re-using the same errors logic.
|
|
94
|
+
//
|
|
95
|
+
// May be passed in place of an array to build a single-element array.
|
|
96
|
+
type errArrayElem struct{ err error }
|
|
97
|
+
|
|
98
|
+
func newErrArrayElem(err error) *errArrayElem {
|
|
99
|
+
e := _errArrayElemPool.Get().(*errArrayElem)
|
|
100
|
+
e.err = err
|
|
101
|
+
return e
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
func (e *errArrayElem) MarshalLogArray(arr ArrayEncoder) error {
|
|
105
|
+
return arr.AppendObject(e)
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
func (e *errArrayElem) MarshalLogObject(enc ObjectEncoder) error {
|
|
109
|
+
return encodeError("error", e.err, enc)
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
func (e *errArrayElem) Free() {
|
|
113
|
+
e.err = nil
|
|
114
|
+
_errArrayElemPool.Put(e)
|
|
115
|
+
}
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
// Copyright (c) 2016 Uber Technologies, Inc.
|
|
2
|
+
//
|
|
3
|
+
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
+
// of this software and associated documentation files (the "Software"), to deal
|
|
5
|
+
// in the Software without restriction, including without limitation the rights
|
|
6
|
+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
+
// copies of the Software, and to permit persons to whom the Software is
|
|
8
|
+
// furnished to do so, subject to the following conditions:
|
|
9
|
+
//
|
|
10
|
+
// The above copyright notice and this permission notice shall be included in
|
|
11
|
+
// all copies or substantial portions of the Software.
|
|
12
|
+
//
|
|
13
|
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
19
|
+
// THE SOFTWARE.
|
|
20
|
+
|
|
21
|
+
package zapcore
|
|
22
|
+
|
|
23
|
+
import (
|
|
24
|
+
"bytes"
|
|
25
|
+
"fmt"
|
|
26
|
+
"math"
|
|
27
|
+
"reflect"
|
|
28
|
+
"time"
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
// A FieldType indicates which member of the Field union struct should be used
|
|
32
|
+
// and how it should be serialized.
|
|
33
|
+
type FieldType uint8
|
|
34
|
+
|
|
35
|
+
const (
|
|
36
|
+
// UnknownType is the default field type. Attempting to add it to an encoder will panic.
|
|
37
|
+
UnknownType FieldType = iota
|
|
38
|
+
// ArrayMarshalerType indicates that the field carries an ArrayMarshaler.
|
|
39
|
+
ArrayMarshalerType
|
|
40
|
+
// ObjectMarshalerType indicates that the field carries an ObjectMarshaler.
|
|
41
|
+
ObjectMarshalerType
|
|
42
|
+
// BinaryType indicates that the field carries an opaque binary blob.
|
|
43
|
+
BinaryType
|
|
44
|
+
// BoolType indicates that the field carries a bool.
|
|
45
|
+
BoolType
|
|
46
|
+
// ByteStringType indicates that the field carries UTF-8 encoded bytes.
|
|
47
|
+
ByteStringType
|
|
48
|
+
// Complex128Type indicates that the field carries a complex128.
|
|
49
|
+
Complex128Type
|
|
50
|
+
// Complex64Type indicates that the field carries a complex128.
|
|
51
|
+
Complex64Type
|
|
52
|
+
// DurationType indicates that the field carries a time.Duration.
|
|
53
|
+
DurationType
|
|
54
|
+
// Float64Type indicates that the field carries a float64.
|
|
55
|
+
Float64Type
|
|
56
|
+
// Float32Type indicates that the field carries a float32.
|
|
57
|
+
Float32Type
|
|
58
|
+
// Int64Type indicates that the field carries an int64.
|
|
59
|
+
Int64Type
|
|
60
|
+
// Int32Type indicates that the field carries an int32.
|
|
61
|
+
Int32Type
|
|
62
|
+
// Int16Type indicates that the field carries an int16.
|
|
63
|
+
Int16Type
|
|
64
|
+
// Int8Type indicates that the field carries an int8.
|
|
65
|
+
Int8Type
|
|
66
|
+
// StringType indicates that the field carries a string.
|
|
67
|
+
StringType
|
|
68
|
+
// TimeType indicates that the field carries a time.Time that is
|
|
69
|
+
// representable by a UnixNano() stored as an int64.
|
|
70
|
+
TimeType
|
|
71
|
+
// TimeFullType indicates that the field carries a time.Time stored as-is.
|
|
72
|
+
TimeFullType
|
|
73
|
+
// Uint64Type indicates that the field carries a uint64.
|
|
74
|
+
Uint64Type
|
|
75
|
+
// Uint32Type indicates that the field carries a uint32.
|
|
76
|
+
Uint32Type
|
|
77
|
+
// Uint16Type indicates that the field carries a uint16.
|
|
78
|
+
Uint16Type
|
|
79
|
+
// Uint8Type indicates that the field carries a uint8.
|
|
80
|
+
Uint8Type
|
|
81
|
+
// UintptrType indicates that the field carries a uintptr.
|
|
82
|
+
UintptrType
|
|
83
|
+
// ReflectType indicates that the field carries an interface{}, which should
|
|
84
|
+
// be serialized using reflection.
|
|
85
|
+
ReflectType
|
|
86
|
+
// NamespaceType signals the beginning of an isolated namespace. All
|
|
87
|
+
// subsequent fields should be added to the new namespace.
|
|
88
|
+
NamespaceType
|
|
89
|
+
// StringerType indicates that the field carries a fmt.Stringer.
|
|
90
|
+
StringerType
|
|
91
|
+
// ErrorType indicates that the field carries an error.
|
|
92
|
+
ErrorType
|
|
93
|
+
// SkipType indicates that the field is a no-op.
|
|
94
|
+
SkipType
|
|
95
|
+
)
|
|
96
|
+
|
|
97
|
+
// A Field is a marshaling operation used to add a key-value pair to a logger's
|
|
98
|
+
// context. Most fields are lazily marshaled, so it's inexpensive to add fields
|
|
99
|
+
// to disabled debug-level log statements.
|
|
100
|
+
type Field struct {
|
|
101
|
+
Key string
|
|
102
|
+
Type FieldType
|
|
103
|
+
Integer int64
|
|
104
|
+
String string
|
|
105
|
+
Interface interface{}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// AddTo exports a field through the ObjectEncoder interface. It's primarily
|
|
109
|
+
// useful to library authors, and shouldn't be necessary in most applications.
|
|
110
|
+
func (f Field) AddTo(enc ObjectEncoder) {
|
|
111
|
+
var err error
|
|
112
|
+
|
|
113
|
+
switch f.Type {
|
|
114
|
+
case ArrayMarshalerType:
|
|
115
|
+
err = enc.AddArray(f.Key, f.Interface.(ArrayMarshaler))
|
|
116
|
+
case ObjectMarshalerType:
|
|
117
|
+
err = enc.AddObject(f.Key, f.Interface.(ObjectMarshaler))
|
|
118
|
+
case BinaryType:
|
|
119
|
+
enc.AddBinary(f.Key, f.Interface.([]byte))
|
|
120
|
+
case BoolType:
|
|
121
|
+
enc.AddBool(f.Key, f.Integer == 1)
|
|
122
|
+
case ByteStringType:
|
|
123
|
+
enc.AddByteString(f.Key, f.Interface.([]byte))
|
|
124
|
+
case Complex128Type:
|
|
125
|
+
enc.AddComplex128(f.Key, f.Interface.(complex128))
|
|
126
|
+
case Complex64Type:
|
|
127
|
+
enc.AddComplex64(f.Key, f.Interface.(complex64))
|
|
128
|
+
case DurationType:
|
|
129
|
+
enc.AddDuration(f.Key, time.Duration(f.Integer))
|
|
130
|
+
case Float64Type:
|
|
131
|
+
enc.AddFloat64(f.Key, math.Float64frombits(uint64(f.Integer)))
|
|
132
|
+
case Float32Type:
|
|
133
|
+
enc.AddFloat32(f.Key, math.Float32frombits(uint32(f.Integer)))
|
|
134
|
+
case Int64Type:
|
|
135
|
+
enc.AddInt64(f.Key, f.Integer)
|
|
136
|
+
case Int32Type:
|
|
137
|
+
enc.AddInt32(f.Key, int32(f.Integer))
|
|
138
|
+
case Int16Type:
|
|
139
|
+
enc.AddInt16(f.Key, int16(f.Integer))
|
|
140
|
+
case Int8Type:
|
|
141
|
+
enc.AddInt8(f.Key, int8(f.Integer))
|
|
142
|
+
case StringType:
|
|
143
|
+
enc.AddString(f.Key, f.String)
|
|
144
|
+
case TimeType:
|
|
145
|
+
if f.Interface != nil {
|
|
146
|
+
enc.AddTime(f.Key, time.Unix(0, f.Integer).In(f.Interface.(*time.Location)))
|
|
147
|
+
} else {
|
|
148
|
+
// Fall back to UTC if location is nil.
|
|
149
|
+
enc.AddTime(f.Key, time.Unix(0, f.Integer))
|
|
150
|
+
}
|
|
151
|
+
case TimeFullType:
|
|
152
|
+
enc.AddTime(f.Key, f.Interface.(time.Time))
|
|
153
|
+
case Uint64Type:
|
|
154
|
+
enc.AddUint64(f.Key, uint64(f.Integer))
|
|
155
|
+
case Uint32Type:
|
|
156
|
+
enc.AddUint32(f.Key, uint32(f.Integer))
|
|
157
|
+
case Uint16Type:
|
|
158
|
+
enc.AddUint16(f.Key, uint16(f.Integer))
|
|
159
|
+
case Uint8Type:
|
|
160
|
+
enc.AddUint8(f.Key, uint8(f.Integer))
|
|
161
|
+
case UintptrType:
|
|
162
|
+
enc.AddUintptr(f.Key, uintptr(f.Integer))
|
|
163
|
+
case ReflectType:
|
|
164
|
+
err = enc.AddReflected(f.Key, f.Interface)
|
|
165
|
+
case NamespaceType:
|
|
166
|
+
enc.OpenNamespace(f.Key)
|
|
167
|
+
case StringerType:
|
|
168
|
+
err = encodeStringer(f.Key, f.Interface, enc)
|
|
169
|
+
case ErrorType:
|
|
170
|
+
encodeError(f.Key, f.Interface.(error), enc)
|
|
171
|
+
case SkipType:
|
|
172
|
+
break
|
|
173
|
+
default:
|
|
174
|
+
panic(fmt.Sprintf("unknown field type: %v", f))
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
if err != nil {
|
|
178
|
+
enc.AddString(fmt.Sprintf("%sError", f.Key), err.Error())
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
// Equals returns whether two fields are equal. For non-primitive types such as
|
|
183
|
+
// errors, marshalers, or reflect types, it uses reflect.DeepEqual.
|
|
184
|
+
func (f Field) Equals(other Field) bool {
|
|
185
|
+
if f.Type != other.Type {
|
|
186
|
+
return false
|
|
187
|
+
}
|
|
188
|
+
if f.Key != other.Key {
|
|
189
|
+
return false
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
switch f.Type {
|
|
193
|
+
case BinaryType, ByteStringType:
|
|
194
|
+
return bytes.Equal(f.Interface.([]byte), other.Interface.([]byte))
|
|
195
|
+
case ArrayMarshalerType, ObjectMarshalerType, ErrorType, ReflectType:
|
|
196
|
+
return reflect.DeepEqual(f.Interface, other.Interface)
|
|
197
|
+
default:
|
|
198
|
+
return f == other
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
func addFields(enc ObjectEncoder, fields []Field) {
|
|
203
|
+
for i := range fields {
|
|
204
|
+
fields[i].AddTo(enc)
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
func encodeStringer(key string, stringer interface{}, enc ObjectEncoder) (retErr error) {
|
|
209
|
+
// Try to capture panics (from nil references or otherwise) when calling
|
|
210
|
+
// the String() method, similar to https://golang.org/src/fmt/print.go#L540
|
|
211
|
+
defer func() {
|
|
212
|
+
if err := recover(); err != nil {
|
|
213
|
+
// If it's a nil pointer, just say "<nil>". The likeliest causes are a
|
|
214
|
+
// Stringer that fails to guard against nil or a nil pointer for a
|
|
215
|
+
// value receiver, and in either case, "<nil>" is a nice result.
|
|
216
|
+
if v := reflect.ValueOf(stringer); v.Kind() == reflect.Ptr && v.IsNil() {
|
|
217
|
+
enc.AddString(key, "<nil>")
|
|
218
|
+
return
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
retErr = fmt.Errorf("PANIC=%v", err)
|
|
222
|
+
}
|
|
223
|
+
}()
|
|
224
|
+
|
|
225
|
+
enc.AddString(key, stringer.(fmt.Stringer).String())
|
|
226
|
+
return nil
|
|
227
|
+
}
|