planetscale 0.3.1 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +9 -1
- data/.github/workflows/gem-push.yml +9 -2
- data/.licenses/go/github.com/matoous/go-nanoid/v2.dep.yml +34 -0
- data/.licenses/go/github.com/planetscale/planetscale-go/planetscale.dep.yml +1 -1
- data/.licenses/go/github.com/planetscale/sql-proxy/proxy.dep.yml +1 -1
- data/.licenses/go/go.uber.org/zap/buffer.dep.yml +1 -1
- data/.licenses/go/go.uber.org/zap/internal/bufferpool.dep.yml +1 -1
- data/.licenses/go/go.uber.org/zap/internal/color.dep.yml +1 -1
- data/.licenses/go/go.uber.org/zap/internal/exit.dep.yml +1 -1
- data/.licenses/go/go.uber.org/zap/zapcore.dep.yml +1 -1
- data/.licenses/go/go.uber.org/zap.dep.yml +1 -1
- data/README.md +2 -0
- data/controller.go +21 -36
- data/go.mod +4 -3
- data/go.sum +32 -18
- data/lib/planetscale/version.rb +1 -1
- data/lib/planetscale.rb +2 -3
- data/planetscale.gemspec +1 -1
- data/proxy/planetscale-darwin.h +1 -1
- data/proxy/planetscale-darwin.so +0 -0
- data/proxy/planetscale-linux.h +1 -1
- data/proxy/planetscale-linux.so +0 -0
- data/proxy.go +1 -5
- metadata +3 -345
- data/vendor/github.com/armon/circbuf/.gitignore +0 -22
- data/vendor/github.com/armon/circbuf/LICENSE +0 -20
- data/vendor/github.com/armon/circbuf/README.md +0 -28
- data/vendor/github.com/armon/circbuf/circbuf.go +0 -92
- data/vendor/github.com/armon/circbuf/go.mod +0 -1
- data/vendor/github.com/golang/protobuf/AUTHORS +0 -3
- data/vendor/github.com/golang/protobuf/CONTRIBUTORS +0 -3
- data/vendor/github.com/golang/protobuf/LICENSE +0 -28
- data/vendor/github.com/golang/protobuf/proto/buffer.go +0 -324
- data/vendor/github.com/golang/protobuf/proto/defaults.go +0 -63
- data/vendor/github.com/golang/protobuf/proto/deprecated.go +0 -113
- data/vendor/github.com/golang/protobuf/proto/discard.go +0 -58
- data/vendor/github.com/golang/protobuf/proto/extensions.go +0 -356
- data/vendor/github.com/golang/protobuf/proto/properties.go +0 -306
- data/vendor/github.com/golang/protobuf/proto/proto.go +0 -167
- data/vendor/github.com/golang/protobuf/proto/registry.go +0 -317
- data/vendor/github.com/golang/protobuf/proto/text_decode.go +0 -801
- data/vendor/github.com/golang/protobuf/proto/text_encode.go +0 -560
- data/vendor/github.com/golang/protobuf/proto/wire.go +0 -78
- data/vendor/github.com/golang/protobuf/proto/wrappers.go +0 -34
- data/vendor/github.com/gorilla/mux/AUTHORS +0 -8
- data/vendor/github.com/gorilla/mux/LICENSE +0 -27
- data/vendor/github.com/gorilla/mux/README.md +0 -805
- data/vendor/github.com/gorilla/mux/doc.go +0 -306
- data/vendor/github.com/gorilla/mux/go.mod +0 -3
- data/vendor/github.com/gorilla/mux/middleware.go +0 -74
- data/vendor/github.com/gorilla/mux/mux.go +0 -606
- data/vendor/github.com/gorilla/mux/regexp.go +0 -388
- data/vendor/github.com/gorilla/mux/route.go +0 -736
- data/vendor/github.com/gorilla/mux/test_helpers.go +0 -19
- data/vendor/github.com/hashicorp/go-cleanhttp/LICENSE +0 -363
- data/vendor/github.com/hashicorp/go-cleanhttp/README.md +0 -30
- data/vendor/github.com/hashicorp/go-cleanhttp/cleanhttp.go +0 -58
- data/vendor/github.com/hashicorp/go-cleanhttp/doc.go +0 -20
- data/vendor/github.com/hashicorp/go-cleanhttp/go.mod +0 -3
- data/vendor/github.com/hashicorp/go-cleanhttp/handlers.go +0 -48
- data/vendor/github.com/mitchellh/go-homedir/LICENSE +0 -21
- data/vendor/github.com/mitchellh/go-homedir/README.md +0 -14
- data/vendor/github.com/mitchellh/go-homedir/go.mod +0 -1
- data/vendor/github.com/mitchellh/go-homedir/homedir.go +0 -167
- data/vendor/github.com/pkg/errors/.gitignore +0 -24
- data/vendor/github.com/pkg/errors/.travis.yml +0 -10
- data/vendor/github.com/pkg/errors/LICENSE +0 -23
- data/vendor/github.com/pkg/errors/Makefile +0 -44
- data/vendor/github.com/pkg/errors/README.md +0 -59
- data/vendor/github.com/pkg/errors/appveyor.yml +0 -32
- data/vendor/github.com/pkg/errors/errors.go +0 -288
- data/vendor/github.com/pkg/errors/go113.go +0 -38
- data/vendor/github.com/pkg/errors/stack.go +0 -177
- data/vendor/github.com/planetscale/planetscale-go/LICENSE +0 -202
- data/vendor/github.com/planetscale/planetscale-go/planetscale/audit_logs.go +0 -136
- data/vendor/github.com/planetscale/planetscale-go/planetscale/backups.go +0 -139
- data/vendor/github.com/planetscale/planetscale-go/planetscale/branches.go +0 -252
- data/vendor/github.com/planetscale/planetscale-go/planetscale/certs.go +0 -166
- data/vendor/github.com/planetscale/planetscale-go/planetscale/client.go +0 -312
- data/vendor/github.com/planetscale/planetscale-go/planetscale/databases.go +0 -133
- data/vendor/github.com/planetscale/planetscale-go/planetscale/deploy_requests.go +0 -368
- data/vendor/github.com/planetscale/planetscale-go/planetscale/organizations.go +0 -103
- data/vendor/github.com/planetscale/planetscale-go/planetscale/regions.go +0 -52
- data/vendor/github.com/planetscale/planetscale-go/planetscale/service_tokens.go +0 -163
- data/vendor/github.com/planetscale/sql-proxy/LICENSE +0 -202
- data/vendor/github.com/planetscale/sql-proxy/proxy/client.go +0 -476
- data/vendor/github.com/planetscale/sql-proxy/proxy/tls_cache.go +0 -73
- data/vendor/go.uber.org/atomic/.codecov.yml +0 -19
- data/vendor/go.uber.org/atomic/.gitignore +0 -12
- data/vendor/go.uber.org/atomic/.travis.yml +0 -27
- data/vendor/go.uber.org/atomic/CHANGELOG.md +0 -76
- data/vendor/go.uber.org/atomic/LICENSE.txt +0 -19
- data/vendor/go.uber.org/atomic/Makefile +0 -78
- data/vendor/go.uber.org/atomic/README.md +0 -63
- data/vendor/go.uber.org/atomic/bool.go +0 -81
- data/vendor/go.uber.org/atomic/bool_ext.go +0 -53
- data/vendor/go.uber.org/atomic/doc.go +0 -23
- data/vendor/go.uber.org/atomic/duration.go +0 -82
- data/vendor/go.uber.org/atomic/duration_ext.go +0 -40
- data/vendor/go.uber.org/atomic/error.go +0 -51
- data/vendor/go.uber.org/atomic/error_ext.go +0 -39
- data/vendor/go.uber.org/atomic/float64.go +0 -76
- data/vendor/go.uber.org/atomic/float64_ext.go +0 -47
- data/vendor/go.uber.org/atomic/gen.go +0 -26
- data/vendor/go.uber.org/atomic/go.mod +0 -8
- data/vendor/go.uber.org/atomic/go.sum +0 -9
- data/vendor/go.uber.org/atomic/int32.go +0 -102
- data/vendor/go.uber.org/atomic/int64.go +0 -102
- data/vendor/go.uber.org/atomic/nocmp.go +0 -35
- data/vendor/go.uber.org/atomic/string.go +0 -54
- data/vendor/go.uber.org/atomic/string_ext.go +0 -43
- data/vendor/go.uber.org/atomic/uint32.go +0 -102
- data/vendor/go.uber.org/atomic/uint64.go +0 -102
- data/vendor/go.uber.org/atomic/value.go +0 -31
- data/vendor/go.uber.org/multierr/.codecov.yml +0 -15
- data/vendor/go.uber.org/multierr/.gitignore +0 -4
- data/vendor/go.uber.org/multierr/.travis.yml +0 -23
- data/vendor/go.uber.org/multierr/CHANGELOG.md +0 -60
- data/vendor/go.uber.org/multierr/LICENSE.txt +0 -19
- data/vendor/go.uber.org/multierr/Makefile +0 -42
- data/vendor/go.uber.org/multierr/README.md +0 -23
- data/vendor/go.uber.org/multierr/error.go +0 -449
- data/vendor/go.uber.org/multierr/glide.yaml +0 -8
- data/vendor/go.uber.org/multierr/go.mod +0 -8
- data/vendor/go.uber.org/multierr/go.sum +0 -11
- data/vendor/go.uber.org/multierr/go113.go +0 -52
- data/vendor/go.uber.org/zap/.codecov.yml +0 -17
- data/vendor/go.uber.org/zap/.gitignore +0 -32
- data/vendor/go.uber.org/zap/.readme.tmpl +0 -109
- data/vendor/go.uber.org/zap/CHANGELOG.md +0 -492
- data/vendor/go.uber.org/zap/CODE_OF_CONDUCT.md +0 -75
- data/vendor/go.uber.org/zap/CONTRIBUTING.md +0 -75
- data/vendor/go.uber.org/zap/FAQ.md +0 -164
- data/vendor/go.uber.org/zap/LICENSE.txt +0 -19
- data/vendor/go.uber.org/zap/Makefile +0 -73
- data/vendor/go.uber.org/zap/README.md +0 -134
- data/vendor/go.uber.org/zap/array.go +0 -320
- data/vendor/go.uber.org/zap/buffer/buffer.go +0 -141
- data/vendor/go.uber.org/zap/buffer/pool.go +0 -49
- data/vendor/go.uber.org/zap/checklicense.sh +0 -17
- data/vendor/go.uber.org/zap/config.go +0 -264
- data/vendor/go.uber.org/zap/doc.go +0 -113
- data/vendor/go.uber.org/zap/encoder.go +0 -79
- data/vendor/go.uber.org/zap/error.go +0 -80
- data/vendor/go.uber.org/zap/field.go +0 -549
- data/vendor/go.uber.org/zap/flag.go +0 -39
- data/vendor/go.uber.org/zap/glide.yaml +0 -34
- data/vendor/go.uber.org/zap/global.go +0 -168
- data/vendor/go.uber.org/zap/global_go112.go +0 -26
- data/vendor/go.uber.org/zap/global_prego112.go +0 -26
- data/vendor/go.uber.org/zap/go.mod +0 -14
- data/vendor/go.uber.org/zap/go.sum +0 -54
- data/vendor/go.uber.org/zap/http_handler.go +0 -132
- data/vendor/go.uber.org/zap/internal/bufferpool/bufferpool.go +0 -31
- data/vendor/go.uber.org/zap/internal/color/color.go +0 -44
- data/vendor/go.uber.org/zap/internal/exit/exit.go +0 -64
- data/vendor/go.uber.org/zap/level.go +0 -132
- data/vendor/go.uber.org/zap/logger.go +0 -348
- data/vendor/go.uber.org/zap/options.go +0 -148
- data/vendor/go.uber.org/zap/sink.go +0 -161
- data/vendor/go.uber.org/zap/stacktrace.go +0 -85
- data/vendor/go.uber.org/zap/sugar.go +0 -315
- data/vendor/go.uber.org/zap/time.go +0 -27
- data/vendor/go.uber.org/zap/writer.go +0 -99
- data/vendor/go.uber.org/zap/zapcore/buffered_write_syncer.go +0 -188
- data/vendor/go.uber.org/zap/zapcore/clock.go +0 -50
- data/vendor/go.uber.org/zap/zapcore/console_encoder.go +0 -161
- data/vendor/go.uber.org/zap/zapcore/core.go +0 -113
- data/vendor/go.uber.org/zap/zapcore/doc.go +0 -24
- data/vendor/go.uber.org/zap/zapcore/encoder.go +0 -443
- data/vendor/go.uber.org/zap/zapcore/entry.go +0 -264
- data/vendor/go.uber.org/zap/zapcore/error.go +0 -132
- data/vendor/go.uber.org/zap/zapcore/field.go +0 -233
- data/vendor/go.uber.org/zap/zapcore/hook.go +0 -68
- data/vendor/go.uber.org/zap/zapcore/increase_level.go +0 -66
- data/vendor/go.uber.org/zap/zapcore/json_encoder.go +0 -534
- data/vendor/go.uber.org/zap/zapcore/level.go +0 -175
- data/vendor/go.uber.org/zap/zapcore/level_strings.go +0 -46
- data/vendor/go.uber.org/zap/zapcore/marshaler.go +0 -61
- data/vendor/go.uber.org/zap/zapcore/memory_encoder.go +0 -179
- data/vendor/go.uber.org/zap/zapcore/sampler.go +0 -208
- data/vendor/go.uber.org/zap/zapcore/tee.go +0 -81
- data/vendor/go.uber.org/zap/zapcore/write_syncer.go +0 -122
- data/vendor/golang.org/x/net/AUTHORS +0 -3
- data/vendor/golang.org/x/net/CONTRIBUTORS +0 -3
- data/vendor/golang.org/x/net/LICENSE +0 -27
- data/vendor/golang.org/x/net/PATENTS +0 -22
- data/vendor/golang.org/x/net/context/context.go +0 -56
- data/vendor/golang.org/x/net/context/ctxhttp/ctxhttp.go +0 -71
- data/vendor/golang.org/x/net/context/go17.go +0 -73
- data/vendor/golang.org/x/net/context/go19.go +0 -21
- data/vendor/golang.org/x/net/context/pre_go17.go +0 -301
- data/vendor/golang.org/x/net/context/pre_go19.go +0 -110
- data/vendor/golang.org/x/oauth2/.travis.yml +0 -13
- data/vendor/golang.org/x/oauth2/AUTHORS +0 -3
- data/vendor/golang.org/x/oauth2/CONTRIBUTING.md +0 -26
- data/vendor/golang.org/x/oauth2/CONTRIBUTORS +0 -3
- data/vendor/golang.org/x/oauth2/LICENSE +0 -27
- data/vendor/golang.org/x/oauth2/README.md +0 -36
- data/vendor/golang.org/x/oauth2/go.mod +0 -9
- data/vendor/golang.org/x/oauth2/go.sum +0 -361
- data/vendor/golang.org/x/oauth2/internal/client_appengine.go +0 -14
- data/vendor/golang.org/x/oauth2/internal/doc.go +0 -6
- data/vendor/golang.org/x/oauth2/internal/oauth2.go +0 -37
- data/vendor/golang.org/x/oauth2/internal/token.go +0 -294
- data/vendor/golang.org/x/oauth2/internal/transport.go +0 -33
- data/vendor/golang.org/x/oauth2/oauth2.go +0 -381
- data/vendor/golang.org/x/oauth2/token.go +0 -178
- data/vendor/golang.org/x/oauth2/transport.go +0 -89
- data/vendor/google.golang.org/appengine/LICENSE +0 -202
- data/vendor/google.golang.org/appengine/internal/api.go +0 -678
- data/vendor/google.golang.org/appengine/internal/api_classic.go +0 -169
- data/vendor/google.golang.org/appengine/internal/api_common.go +0 -123
- data/vendor/google.golang.org/appengine/internal/app_id.go +0 -28
- data/vendor/google.golang.org/appengine/internal/base/api_base.pb.go +0 -308
- data/vendor/google.golang.org/appengine/internal/base/api_base.proto +0 -33
- data/vendor/google.golang.org/appengine/internal/datastore/datastore_v3.pb.go +0 -4367
- data/vendor/google.golang.org/appengine/internal/datastore/datastore_v3.proto +0 -551
- data/vendor/google.golang.org/appengine/internal/identity.go +0 -55
- data/vendor/google.golang.org/appengine/internal/identity_classic.go +0 -61
- data/vendor/google.golang.org/appengine/internal/identity_flex.go +0 -11
- data/vendor/google.golang.org/appengine/internal/identity_vm.go +0 -134
- data/vendor/google.golang.org/appengine/internal/internal.go +0 -110
- data/vendor/google.golang.org/appengine/internal/log/log_service.pb.go +0 -1313
- data/vendor/google.golang.org/appengine/internal/log/log_service.proto +0 -150
- data/vendor/google.golang.org/appengine/internal/main.go +0 -16
- data/vendor/google.golang.org/appengine/internal/main_common.go +0 -7
- data/vendor/google.golang.org/appengine/internal/main_vm.go +0 -69
- data/vendor/google.golang.org/appengine/internal/metadata.go +0 -60
- data/vendor/google.golang.org/appengine/internal/net.go +0 -56
- data/vendor/google.golang.org/appengine/internal/regen.sh +0 -40
- data/vendor/google.golang.org/appengine/internal/remote_api/remote_api.pb.go +0 -361
- data/vendor/google.golang.org/appengine/internal/remote_api/remote_api.proto +0 -44
- data/vendor/google.golang.org/appengine/internal/transaction.go +0 -115
- data/vendor/google.golang.org/appengine/internal/urlfetch/urlfetch_service.pb.go +0 -527
- data/vendor/google.golang.org/appengine/internal/urlfetch/urlfetch_service.proto +0 -64
- data/vendor/google.golang.org/appengine/urlfetch/urlfetch.go +0 -210
- data/vendor/google.golang.org/protobuf/AUTHORS +0 -3
- data/vendor/google.golang.org/protobuf/CONTRIBUTORS +0 -3
- data/vendor/google.golang.org/protobuf/LICENSE +0 -27
- data/vendor/google.golang.org/protobuf/PATENTS +0 -22
- data/vendor/google.golang.org/protobuf/encoding/prototext/decode.go +0 -773
- data/vendor/google.golang.org/protobuf/encoding/prototext/doc.go +0 -7
- data/vendor/google.golang.org/protobuf/encoding/prototext/encode.go +0 -371
- data/vendor/google.golang.org/protobuf/encoding/protowire/wire.go +0 -538
- data/vendor/google.golang.org/protobuf/internal/descfmt/stringer.go +0 -318
- data/vendor/google.golang.org/protobuf/internal/descopts/options.go +0 -29
- data/vendor/google.golang.org/protobuf/internal/detrand/rand.go +0 -69
- data/vendor/google.golang.org/protobuf/internal/encoding/defval/default.go +0 -213
- data/vendor/google.golang.org/protobuf/internal/encoding/messageset/messageset.go +0 -241
- data/vendor/google.golang.org/protobuf/internal/encoding/tag/tag.go +0 -207
- data/vendor/google.golang.org/protobuf/internal/encoding/text/decode.go +0 -665
- data/vendor/google.golang.org/protobuf/internal/encoding/text/decode_number.go +0 -190
- data/vendor/google.golang.org/protobuf/internal/encoding/text/decode_string.go +0 -161
- data/vendor/google.golang.org/protobuf/internal/encoding/text/decode_token.go +0 -373
- data/vendor/google.golang.org/protobuf/internal/encoding/text/doc.go +0 -29
- data/vendor/google.golang.org/protobuf/internal/encoding/text/encode.go +0 -265
- data/vendor/google.golang.org/protobuf/internal/errors/errors.go +0 -89
- data/vendor/google.golang.org/protobuf/internal/errors/is_go112.go +0 -39
- data/vendor/google.golang.org/protobuf/internal/errors/is_go113.go +0 -12
- data/vendor/google.golang.org/protobuf/internal/filedesc/build.go +0 -158
- data/vendor/google.golang.org/protobuf/internal/filedesc/desc.go +0 -631
- data/vendor/google.golang.org/protobuf/internal/filedesc/desc_init.go +0 -471
- data/vendor/google.golang.org/protobuf/internal/filedesc/desc_lazy.go +0 -704
- data/vendor/google.golang.org/protobuf/internal/filedesc/desc_list.go +0 -450
- data/vendor/google.golang.org/protobuf/internal/filedesc/desc_list_gen.go +0 -356
- data/vendor/google.golang.org/protobuf/internal/filedesc/placeholder.go +0 -107
- data/vendor/google.golang.org/protobuf/internal/filetype/build.go +0 -297
- data/vendor/google.golang.org/protobuf/internal/flags/flags.go +0 -24
- data/vendor/google.golang.org/protobuf/internal/flags/proto_legacy_disable.go +0 -9
- data/vendor/google.golang.org/protobuf/internal/flags/proto_legacy_enable.go +0 -9
- data/vendor/google.golang.org/protobuf/internal/genid/any_gen.go +0 -34
- data/vendor/google.golang.org/protobuf/internal/genid/api_gen.go +0 -106
- data/vendor/google.golang.org/protobuf/internal/genid/descriptor_gen.go +0 -829
- data/vendor/google.golang.org/protobuf/internal/genid/doc.go +0 -11
- data/vendor/google.golang.org/protobuf/internal/genid/duration_gen.go +0 -34
- data/vendor/google.golang.org/protobuf/internal/genid/empty_gen.go +0 -19
- data/vendor/google.golang.org/protobuf/internal/genid/field_mask_gen.go +0 -31
- data/vendor/google.golang.org/protobuf/internal/genid/goname.go +0 -25
- data/vendor/google.golang.org/protobuf/internal/genid/map_entry.go +0 -16
- data/vendor/google.golang.org/protobuf/internal/genid/source_context_gen.go +0 -31
- data/vendor/google.golang.org/protobuf/internal/genid/struct_gen.go +0 -116
- data/vendor/google.golang.org/protobuf/internal/genid/timestamp_gen.go +0 -34
- data/vendor/google.golang.org/protobuf/internal/genid/type_gen.go +0 -184
- data/vendor/google.golang.org/protobuf/internal/genid/wrappers.go +0 -13
- data/vendor/google.golang.org/protobuf/internal/genid/wrappers_gen.go +0 -175
- data/vendor/google.golang.org/protobuf/internal/impl/api_export.go +0 -177
- data/vendor/google.golang.org/protobuf/internal/impl/checkinit.go +0 -141
- data/vendor/google.golang.org/protobuf/internal/impl/codec_extension.go +0 -223
- data/vendor/google.golang.org/protobuf/internal/impl/codec_field.go +0 -830
- data/vendor/google.golang.org/protobuf/internal/impl/codec_gen.go +0 -5637
- data/vendor/google.golang.org/protobuf/internal/impl/codec_map.go +0 -388
- data/vendor/google.golang.org/protobuf/internal/impl/codec_map_go111.go +0 -37
- data/vendor/google.golang.org/protobuf/internal/impl/codec_map_go112.go +0 -11
- data/vendor/google.golang.org/protobuf/internal/impl/codec_message.go +0 -217
- data/vendor/google.golang.org/protobuf/internal/impl/codec_messageset.go +0 -123
- data/vendor/google.golang.org/protobuf/internal/impl/codec_reflect.go +0 -209
- data/vendor/google.golang.org/protobuf/internal/impl/codec_tables.go +0 -557
- data/vendor/google.golang.org/protobuf/internal/impl/codec_unsafe.go +0 -17
- data/vendor/google.golang.org/protobuf/internal/impl/convert.go +0 -496
- data/vendor/google.golang.org/protobuf/internal/impl/convert_list.go +0 -141
- data/vendor/google.golang.org/protobuf/internal/impl/convert_map.go +0 -121
- data/vendor/google.golang.org/protobuf/internal/impl/decode.go +0 -276
- data/vendor/google.golang.org/protobuf/internal/impl/encode.go +0 -201
- data/vendor/google.golang.org/protobuf/internal/impl/enum.go +0 -21
- data/vendor/google.golang.org/protobuf/internal/impl/extension.go +0 -156
- data/vendor/google.golang.org/protobuf/internal/impl/legacy_enum.go +0 -219
- data/vendor/google.golang.org/protobuf/internal/impl/legacy_export.go +0 -92
- data/vendor/google.golang.org/protobuf/internal/impl/legacy_extension.go +0 -176
- data/vendor/google.golang.org/protobuf/internal/impl/legacy_file.go +0 -81
- data/vendor/google.golang.org/protobuf/internal/impl/legacy_message.go +0 -558
- data/vendor/google.golang.org/protobuf/internal/impl/merge.go +0 -176
- data/vendor/google.golang.org/protobuf/internal/impl/merge_gen.go +0 -209
- data/vendor/google.golang.org/protobuf/internal/impl/message.go +0 -276
- data/vendor/google.golang.org/protobuf/internal/impl/message_reflect.go +0 -465
- data/vendor/google.golang.org/protobuf/internal/impl/message_reflect_field.go +0 -543
- data/vendor/google.golang.org/protobuf/internal/impl/message_reflect_gen.go +0 -249
- data/vendor/google.golang.org/protobuf/internal/impl/pointer_reflect.go +0 -178
- data/vendor/google.golang.org/protobuf/internal/impl/pointer_unsafe.go +0 -174
- data/vendor/google.golang.org/protobuf/internal/impl/validate.go +0 -576
- data/vendor/google.golang.org/protobuf/internal/impl/weak.go +0 -74
- data/vendor/google.golang.org/protobuf/internal/order/order.go +0 -89
- data/vendor/google.golang.org/protobuf/internal/order/range.go +0 -115
- data/vendor/google.golang.org/protobuf/internal/pragma/pragma.go +0 -29
- data/vendor/google.golang.org/protobuf/internal/set/ints.go +0 -58
- data/vendor/google.golang.org/protobuf/internal/strs/strings.go +0 -196
- data/vendor/google.golang.org/protobuf/internal/strs/strings_pure.go +0 -27
- data/vendor/google.golang.org/protobuf/internal/strs/strings_unsafe.go +0 -94
- data/vendor/google.golang.org/protobuf/internal/version/version.go +0 -79
- data/vendor/google.golang.org/protobuf/proto/checkinit.go +0 -71
- data/vendor/google.golang.org/protobuf/proto/decode.go +0 -278
- data/vendor/google.golang.org/protobuf/proto/decode_gen.go +0 -603
- data/vendor/google.golang.org/protobuf/proto/doc.go +0 -94
- data/vendor/google.golang.org/protobuf/proto/encode.go +0 -319
- data/vendor/google.golang.org/protobuf/proto/encode_gen.go +0 -97
- data/vendor/google.golang.org/protobuf/proto/equal.go +0 -167
- data/vendor/google.golang.org/protobuf/proto/extension.go +0 -92
- data/vendor/google.golang.org/protobuf/proto/merge.go +0 -139
- data/vendor/google.golang.org/protobuf/proto/messageset.go +0 -93
- data/vendor/google.golang.org/protobuf/proto/proto.go +0 -43
- data/vendor/google.golang.org/protobuf/proto/proto_methods.go +0 -19
- data/vendor/google.golang.org/protobuf/proto/proto_reflect.go +0 -19
- data/vendor/google.golang.org/protobuf/proto/reset.go +0 -43
- data/vendor/google.golang.org/protobuf/proto/size.go +0 -97
- data/vendor/google.golang.org/protobuf/proto/size_gen.go +0 -55
- data/vendor/google.golang.org/protobuf/proto/wrappers.go +0 -29
- data/vendor/google.golang.org/protobuf/reflect/protodesc/desc.go +0 -276
- data/vendor/google.golang.org/protobuf/reflect/protodesc/desc_init.go +0 -248
- data/vendor/google.golang.org/protobuf/reflect/protodesc/desc_resolve.go +0 -286
- data/vendor/google.golang.org/protobuf/reflect/protodesc/desc_validate.go +0 -374
- data/vendor/google.golang.org/protobuf/reflect/protodesc/proto.go +0 -252
- data/vendor/google.golang.org/protobuf/reflect/protoreflect/methods.go +0 -77
- data/vendor/google.golang.org/protobuf/reflect/protoreflect/proto.go +0 -504
- data/vendor/google.golang.org/protobuf/reflect/protoreflect/source.go +0 -128
- data/vendor/google.golang.org/protobuf/reflect/protoreflect/source_gen.go +0 -461
- data/vendor/google.golang.org/protobuf/reflect/protoreflect/type.go +0 -665
- data/vendor/google.golang.org/protobuf/reflect/protoreflect/value.go +0 -285
- data/vendor/google.golang.org/protobuf/reflect/protoreflect/value_pure.go +0 -59
- data/vendor/google.golang.org/protobuf/reflect/protoreflect/value_union.go +0 -411
- data/vendor/google.golang.org/protobuf/reflect/protoreflect/value_unsafe.go +0 -98
- data/vendor/google.golang.org/protobuf/reflect/protoregistry/registry.go +0 -869
- data/vendor/google.golang.org/protobuf/runtime/protoiface/legacy.go +0 -15
- data/vendor/google.golang.org/protobuf/runtime/protoiface/methods.go +0 -167
- data/vendor/google.golang.org/protobuf/runtime/protoimpl/impl.go +0 -44
- data/vendor/google.golang.org/protobuf/runtime/protoimpl/version.go +0 -56
- data/vendor/google.golang.org/protobuf/types/descriptorpb/descriptor.pb.go +0 -4039
- data/vendor/modules.txt +0 -79
@@ -1,132 +0,0 @@
|
|
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 zap
|
22
|
-
|
23
|
-
import (
|
24
|
-
"go.uber.org/atomic"
|
25
|
-
"go.uber.org/zap/zapcore"
|
26
|
-
)
|
27
|
-
|
28
|
-
const (
|
29
|
-
// DebugLevel logs are typically voluminous, and are usually disabled in
|
30
|
-
// production.
|
31
|
-
DebugLevel = zapcore.DebugLevel
|
32
|
-
// InfoLevel is the default logging priority.
|
33
|
-
InfoLevel = zapcore.InfoLevel
|
34
|
-
// WarnLevel logs are more important than Info, but don't need individual
|
35
|
-
// human review.
|
36
|
-
WarnLevel = zapcore.WarnLevel
|
37
|
-
// ErrorLevel logs are high-priority. If an application is running smoothly,
|
38
|
-
// it shouldn't generate any error-level logs.
|
39
|
-
ErrorLevel = zapcore.ErrorLevel
|
40
|
-
// DPanicLevel logs are particularly important errors. In development the
|
41
|
-
// logger panics after writing the message.
|
42
|
-
DPanicLevel = zapcore.DPanicLevel
|
43
|
-
// PanicLevel logs a message, then panics.
|
44
|
-
PanicLevel = zapcore.PanicLevel
|
45
|
-
// FatalLevel logs a message, then calls os.Exit(1).
|
46
|
-
FatalLevel = zapcore.FatalLevel
|
47
|
-
)
|
48
|
-
|
49
|
-
// LevelEnablerFunc is a convenient way to implement zapcore.LevelEnabler with
|
50
|
-
// an anonymous function.
|
51
|
-
//
|
52
|
-
// It's particularly useful when splitting log output between different
|
53
|
-
// outputs (e.g., standard error and standard out). For sample code, see the
|
54
|
-
// package-level AdvancedConfiguration example.
|
55
|
-
type LevelEnablerFunc func(zapcore.Level) bool
|
56
|
-
|
57
|
-
// Enabled calls the wrapped function.
|
58
|
-
func (f LevelEnablerFunc) Enabled(lvl zapcore.Level) bool { return f(lvl) }
|
59
|
-
|
60
|
-
// An AtomicLevel is an atomically changeable, dynamic logging level. It lets
|
61
|
-
// you safely change the log level of a tree of loggers (the root logger and
|
62
|
-
// any children created by adding context) at runtime.
|
63
|
-
//
|
64
|
-
// The AtomicLevel itself is an http.Handler that serves a JSON endpoint to
|
65
|
-
// alter its level.
|
66
|
-
//
|
67
|
-
// AtomicLevels must be created with the NewAtomicLevel constructor to allocate
|
68
|
-
// their internal atomic pointer.
|
69
|
-
type AtomicLevel struct {
|
70
|
-
l *atomic.Int32
|
71
|
-
}
|
72
|
-
|
73
|
-
// NewAtomicLevel creates an AtomicLevel with InfoLevel and above logging
|
74
|
-
// enabled.
|
75
|
-
func NewAtomicLevel() AtomicLevel {
|
76
|
-
return AtomicLevel{
|
77
|
-
l: atomic.NewInt32(int32(InfoLevel)),
|
78
|
-
}
|
79
|
-
}
|
80
|
-
|
81
|
-
// NewAtomicLevelAt is a convenience function that creates an AtomicLevel
|
82
|
-
// and then calls SetLevel with the given level.
|
83
|
-
func NewAtomicLevelAt(l zapcore.Level) AtomicLevel {
|
84
|
-
a := NewAtomicLevel()
|
85
|
-
a.SetLevel(l)
|
86
|
-
return a
|
87
|
-
}
|
88
|
-
|
89
|
-
// Enabled implements the zapcore.LevelEnabler interface, which allows the
|
90
|
-
// AtomicLevel to be used in place of traditional static levels.
|
91
|
-
func (lvl AtomicLevel) Enabled(l zapcore.Level) bool {
|
92
|
-
return lvl.Level().Enabled(l)
|
93
|
-
}
|
94
|
-
|
95
|
-
// Level returns the minimum enabled log level.
|
96
|
-
func (lvl AtomicLevel) Level() zapcore.Level {
|
97
|
-
return zapcore.Level(int8(lvl.l.Load()))
|
98
|
-
}
|
99
|
-
|
100
|
-
// SetLevel alters the logging level.
|
101
|
-
func (lvl AtomicLevel) SetLevel(l zapcore.Level) {
|
102
|
-
lvl.l.Store(int32(l))
|
103
|
-
}
|
104
|
-
|
105
|
-
// String returns the string representation of the underlying Level.
|
106
|
-
func (lvl AtomicLevel) String() string {
|
107
|
-
return lvl.Level().String()
|
108
|
-
}
|
109
|
-
|
110
|
-
// UnmarshalText unmarshals the text to an AtomicLevel. It uses the same text
|
111
|
-
// representations as the static zapcore.Levels ("debug", "info", "warn",
|
112
|
-
// "error", "dpanic", "panic", and "fatal").
|
113
|
-
func (lvl *AtomicLevel) UnmarshalText(text []byte) error {
|
114
|
-
if lvl.l == nil {
|
115
|
-
lvl.l = &atomic.Int32{}
|
116
|
-
}
|
117
|
-
|
118
|
-
var l zapcore.Level
|
119
|
-
if err := l.UnmarshalText(text); err != nil {
|
120
|
-
return err
|
121
|
-
}
|
122
|
-
|
123
|
-
lvl.SetLevel(l)
|
124
|
-
return nil
|
125
|
-
}
|
126
|
-
|
127
|
-
// MarshalText marshals the AtomicLevel to a byte slice. It uses the same
|
128
|
-
// text representation as the static zapcore.Levels ("debug", "info", "warn",
|
129
|
-
// "error", "dpanic", "panic", and "fatal").
|
130
|
-
func (lvl AtomicLevel) MarshalText() (text []byte, err error) {
|
131
|
-
return lvl.Level().MarshalText()
|
132
|
-
}
|
@@ -1,348 +0,0 @@
|
|
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 zap
|
22
|
-
|
23
|
-
import (
|
24
|
-
"fmt"
|
25
|
-
"io/ioutil"
|
26
|
-
"os"
|
27
|
-
"runtime"
|
28
|
-
"strings"
|
29
|
-
|
30
|
-
"go.uber.org/zap/zapcore"
|
31
|
-
)
|
32
|
-
|
33
|
-
// A Logger provides fast, leveled, structured logging. All methods are safe
|
34
|
-
// for concurrent use.
|
35
|
-
//
|
36
|
-
// The Logger is designed for contexts in which every microsecond and every
|
37
|
-
// allocation matters, so its API intentionally favors performance and type
|
38
|
-
// safety over brevity. For most applications, the SugaredLogger strikes a
|
39
|
-
// better balance between performance and ergonomics.
|
40
|
-
type Logger struct {
|
41
|
-
core zapcore.Core
|
42
|
-
|
43
|
-
development bool
|
44
|
-
addCaller bool
|
45
|
-
onFatal zapcore.CheckWriteAction // default is WriteThenFatal
|
46
|
-
|
47
|
-
name string
|
48
|
-
errorOutput zapcore.WriteSyncer
|
49
|
-
|
50
|
-
addStack zapcore.LevelEnabler
|
51
|
-
|
52
|
-
callerSkip int
|
53
|
-
|
54
|
-
clock zapcore.Clock
|
55
|
-
}
|
56
|
-
|
57
|
-
// New constructs a new Logger from the provided zapcore.Core and Options. If
|
58
|
-
// the passed zapcore.Core is nil, it falls back to using a no-op
|
59
|
-
// implementation.
|
60
|
-
//
|
61
|
-
// This is the most flexible way to construct a Logger, but also the most
|
62
|
-
// verbose. For typical use cases, the highly-opinionated presets
|
63
|
-
// (NewProduction, NewDevelopment, and NewExample) or the Config struct are
|
64
|
-
// more convenient.
|
65
|
-
//
|
66
|
-
// For sample code, see the package-level AdvancedConfiguration example.
|
67
|
-
func New(core zapcore.Core, options ...Option) *Logger {
|
68
|
-
if core == nil {
|
69
|
-
return NewNop()
|
70
|
-
}
|
71
|
-
log := &Logger{
|
72
|
-
core: core,
|
73
|
-
errorOutput: zapcore.Lock(os.Stderr),
|
74
|
-
addStack: zapcore.FatalLevel + 1,
|
75
|
-
clock: zapcore.DefaultClock,
|
76
|
-
}
|
77
|
-
return log.WithOptions(options...)
|
78
|
-
}
|
79
|
-
|
80
|
-
// NewNop returns a no-op Logger. It never writes out logs or internal errors,
|
81
|
-
// and it never runs user-defined hooks.
|
82
|
-
//
|
83
|
-
// Using WithOptions to replace the Core or error output of a no-op Logger can
|
84
|
-
// re-enable logging.
|
85
|
-
func NewNop() *Logger {
|
86
|
-
return &Logger{
|
87
|
-
core: zapcore.NewNopCore(),
|
88
|
-
errorOutput: zapcore.AddSync(ioutil.Discard),
|
89
|
-
addStack: zapcore.FatalLevel + 1,
|
90
|
-
clock: zapcore.DefaultClock,
|
91
|
-
}
|
92
|
-
}
|
93
|
-
|
94
|
-
// NewProduction builds a sensible production Logger that writes InfoLevel and
|
95
|
-
// above logs to standard error as JSON.
|
96
|
-
//
|
97
|
-
// It's a shortcut for NewProductionConfig().Build(...Option).
|
98
|
-
func NewProduction(options ...Option) (*Logger, error) {
|
99
|
-
return NewProductionConfig().Build(options...)
|
100
|
-
}
|
101
|
-
|
102
|
-
// NewDevelopment builds a development Logger that writes DebugLevel and above
|
103
|
-
// logs to standard error in a human-friendly format.
|
104
|
-
//
|
105
|
-
// It's a shortcut for NewDevelopmentConfig().Build(...Option).
|
106
|
-
func NewDevelopment(options ...Option) (*Logger, error) {
|
107
|
-
return NewDevelopmentConfig().Build(options...)
|
108
|
-
}
|
109
|
-
|
110
|
-
// NewExample builds a Logger that's designed for use in zap's testable
|
111
|
-
// examples. It writes DebugLevel and above logs to standard out as JSON, but
|
112
|
-
// omits the timestamp and calling function to keep example output
|
113
|
-
// short and deterministic.
|
114
|
-
func NewExample(options ...Option) *Logger {
|
115
|
-
encoderCfg := zapcore.EncoderConfig{
|
116
|
-
MessageKey: "msg",
|
117
|
-
LevelKey: "level",
|
118
|
-
NameKey: "logger",
|
119
|
-
EncodeLevel: zapcore.LowercaseLevelEncoder,
|
120
|
-
EncodeTime: zapcore.ISO8601TimeEncoder,
|
121
|
-
EncodeDuration: zapcore.StringDurationEncoder,
|
122
|
-
}
|
123
|
-
core := zapcore.NewCore(zapcore.NewJSONEncoder(encoderCfg), os.Stdout, DebugLevel)
|
124
|
-
return New(core).WithOptions(options...)
|
125
|
-
}
|
126
|
-
|
127
|
-
// Sugar wraps the Logger to provide a more ergonomic, but slightly slower,
|
128
|
-
// API. Sugaring a Logger is quite inexpensive, so it's reasonable for a
|
129
|
-
// single application to use both Loggers and SugaredLoggers, converting
|
130
|
-
// between them on the boundaries of performance-sensitive code.
|
131
|
-
func (log *Logger) Sugar() *SugaredLogger {
|
132
|
-
core := log.clone()
|
133
|
-
core.callerSkip += 2
|
134
|
-
return &SugaredLogger{core}
|
135
|
-
}
|
136
|
-
|
137
|
-
// Named adds a new path segment to the logger's name. Segments are joined by
|
138
|
-
// periods. By default, Loggers are unnamed.
|
139
|
-
func (log *Logger) Named(s string) *Logger {
|
140
|
-
if s == "" {
|
141
|
-
return log
|
142
|
-
}
|
143
|
-
l := log.clone()
|
144
|
-
if log.name == "" {
|
145
|
-
l.name = s
|
146
|
-
} else {
|
147
|
-
l.name = strings.Join([]string{l.name, s}, ".")
|
148
|
-
}
|
149
|
-
return l
|
150
|
-
}
|
151
|
-
|
152
|
-
// WithOptions clones the current Logger, applies the supplied Options, and
|
153
|
-
// returns the resulting Logger. It's safe to use concurrently.
|
154
|
-
func (log *Logger) WithOptions(opts ...Option) *Logger {
|
155
|
-
c := log.clone()
|
156
|
-
for _, opt := range opts {
|
157
|
-
opt.apply(c)
|
158
|
-
}
|
159
|
-
return c
|
160
|
-
}
|
161
|
-
|
162
|
-
// With creates a child logger and adds structured context to it. Fields added
|
163
|
-
// to the child don't affect the parent, and vice versa.
|
164
|
-
func (log *Logger) With(fields ...Field) *Logger {
|
165
|
-
if len(fields) == 0 {
|
166
|
-
return log
|
167
|
-
}
|
168
|
-
l := log.clone()
|
169
|
-
l.core = l.core.With(fields)
|
170
|
-
return l
|
171
|
-
}
|
172
|
-
|
173
|
-
// Check returns a CheckedEntry if logging a message at the specified level
|
174
|
-
// is enabled. It's a completely optional optimization; in high-performance
|
175
|
-
// applications, Check can help avoid allocating a slice to hold fields.
|
176
|
-
func (log *Logger) Check(lvl zapcore.Level, msg string) *zapcore.CheckedEntry {
|
177
|
-
return log.check(lvl, msg)
|
178
|
-
}
|
179
|
-
|
180
|
-
// Debug logs a message at DebugLevel. The message includes any fields passed
|
181
|
-
// at the log site, as well as any fields accumulated on the logger.
|
182
|
-
func (log *Logger) Debug(msg string, fields ...Field) {
|
183
|
-
if ce := log.check(DebugLevel, msg); ce != nil {
|
184
|
-
ce.Write(fields...)
|
185
|
-
}
|
186
|
-
}
|
187
|
-
|
188
|
-
// Info logs a message at InfoLevel. The message includes any fields passed
|
189
|
-
// at the log site, as well as any fields accumulated on the logger.
|
190
|
-
func (log *Logger) Info(msg string, fields ...Field) {
|
191
|
-
if ce := log.check(InfoLevel, msg); ce != nil {
|
192
|
-
ce.Write(fields...)
|
193
|
-
}
|
194
|
-
}
|
195
|
-
|
196
|
-
// Warn logs a message at WarnLevel. The message includes any fields passed
|
197
|
-
// at the log site, as well as any fields accumulated on the logger.
|
198
|
-
func (log *Logger) Warn(msg string, fields ...Field) {
|
199
|
-
if ce := log.check(WarnLevel, msg); ce != nil {
|
200
|
-
ce.Write(fields...)
|
201
|
-
}
|
202
|
-
}
|
203
|
-
|
204
|
-
// Error logs a message at ErrorLevel. The message includes any fields passed
|
205
|
-
// at the log site, as well as any fields accumulated on the logger.
|
206
|
-
func (log *Logger) Error(msg string, fields ...Field) {
|
207
|
-
if ce := log.check(ErrorLevel, msg); ce != nil {
|
208
|
-
ce.Write(fields...)
|
209
|
-
}
|
210
|
-
}
|
211
|
-
|
212
|
-
// DPanic logs a message at DPanicLevel. The message includes any fields
|
213
|
-
// passed at the log site, as well as any fields accumulated on the logger.
|
214
|
-
//
|
215
|
-
// If the logger is in development mode, it then panics (DPanic means
|
216
|
-
// "development panic"). This is useful for catching errors that are
|
217
|
-
// recoverable, but shouldn't ever happen.
|
218
|
-
func (log *Logger) DPanic(msg string, fields ...Field) {
|
219
|
-
if ce := log.check(DPanicLevel, msg); ce != nil {
|
220
|
-
ce.Write(fields...)
|
221
|
-
}
|
222
|
-
}
|
223
|
-
|
224
|
-
// Panic logs a message at PanicLevel. The message includes any fields passed
|
225
|
-
// at the log site, as well as any fields accumulated on the logger.
|
226
|
-
//
|
227
|
-
// The logger then panics, even if logging at PanicLevel is disabled.
|
228
|
-
func (log *Logger) Panic(msg string, fields ...Field) {
|
229
|
-
if ce := log.check(PanicLevel, msg); ce != nil {
|
230
|
-
ce.Write(fields...)
|
231
|
-
}
|
232
|
-
}
|
233
|
-
|
234
|
-
// Fatal logs a message at FatalLevel. The message includes any fields passed
|
235
|
-
// at the log site, as well as any fields accumulated on the logger.
|
236
|
-
//
|
237
|
-
// The logger then calls os.Exit(1), even if logging at FatalLevel is
|
238
|
-
// disabled.
|
239
|
-
func (log *Logger) Fatal(msg string, fields ...Field) {
|
240
|
-
if ce := log.check(FatalLevel, msg); ce != nil {
|
241
|
-
ce.Write(fields...)
|
242
|
-
}
|
243
|
-
}
|
244
|
-
|
245
|
-
// Sync calls the underlying Core's Sync method, flushing any buffered log
|
246
|
-
// entries. Applications should take care to call Sync before exiting.
|
247
|
-
func (log *Logger) Sync() error {
|
248
|
-
return log.core.Sync()
|
249
|
-
}
|
250
|
-
|
251
|
-
// Core returns the Logger's underlying zapcore.Core.
|
252
|
-
func (log *Logger) Core() zapcore.Core {
|
253
|
-
return log.core
|
254
|
-
}
|
255
|
-
|
256
|
-
func (log *Logger) clone() *Logger {
|
257
|
-
copy := *log
|
258
|
-
return ©
|
259
|
-
}
|
260
|
-
|
261
|
-
func (log *Logger) check(lvl zapcore.Level, msg string) *zapcore.CheckedEntry {
|
262
|
-
// check must always be called directly by a method in the Logger interface
|
263
|
-
// (e.g., Check, Info, Fatal).
|
264
|
-
const callerSkipOffset = 2
|
265
|
-
|
266
|
-
// Check the level first to reduce the cost of disabled log calls.
|
267
|
-
// Since Panic and higher may exit, we skip the optimization for those levels.
|
268
|
-
if lvl < zapcore.DPanicLevel && !log.core.Enabled(lvl) {
|
269
|
-
return nil
|
270
|
-
}
|
271
|
-
|
272
|
-
// Create basic checked entry thru the core; this will be non-nil if the
|
273
|
-
// log message will actually be written somewhere.
|
274
|
-
ent := zapcore.Entry{
|
275
|
-
LoggerName: log.name,
|
276
|
-
Time: log.clock.Now(),
|
277
|
-
Level: lvl,
|
278
|
-
Message: msg,
|
279
|
-
}
|
280
|
-
ce := log.core.Check(ent, nil)
|
281
|
-
willWrite := ce != nil
|
282
|
-
|
283
|
-
// Set up any required terminal behavior.
|
284
|
-
switch ent.Level {
|
285
|
-
case zapcore.PanicLevel:
|
286
|
-
ce = ce.Should(ent, zapcore.WriteThenPanic)
|
287
|
-
case zapcore.FatalLevel:
|
288
|
-
onFatal := log.onFatal
|
289
|
-
// Noop is the default value for CheckWriteAction, and it leads to
|
290
|
-
// continued execution after a Fatal which is unexpected.
|
291
|
-
if onFatal == zapcore.WriteThenNoop {
|
292
|
-
onFatal = zapcore.WriteThenFatal
|
293
|
-
}
|
294
|
-
ce = ce.Should(ent, onFatal)
|
295
|
-
case zapcore.DPanicLevel:
|
296
|
-
if log.development {
|
297
|
-
ce = ce.Should(ent, zapcore.WriteThenPanic)
|
298
|
-
}
|
299
|
-
}
|
300
|
-
|
301
|
-
// Only do further annotation if we're going to write this message; checked
|
302
|
-
// entries that exist only for terminal behavior don't benefit from
|
303
|
-
// annotation.
|
304
|
-
if !willWrite {
|
305
|
-
return ce
|
306
|
-
}
|
307
|
-
|
308
|
-
// Thread the error output through to the CheckedEntry.
|
309
|
-
ce.ErrorOutput = log.errorOutput
|
310
|
-
if log.addCaller {
|
311
|
-
frame, defined := getCallerFrame(log.callerSkip + callerSkipOffset)
|
312
|
-
if !defined {
|
313
|
-
fmt.Fprintf(log.errorOutput, "%v Logger.check error: failed to get caller\n", ent.Time.UTC())
|
314
|
-
log.errorOutput.Sync()
|
315
|
-
}
|
316
|
-
|
317
|
-
ce.Entry.Caller = zapcore.EntryCaller{
|
318
|
-
Defined: defined,
|
319
|
-
PC: frame.PC,
|
320
|
-
File: frame.File,
|
321
|
-
Line: frame.Line,
|
322
|
-
Function: frame.Function,
|
323
|
-
}
|
324
|
-
}
|
325
|
-
if log.addStack.Enabled(ce.Entry.Level) {
|
326
|
-
ce.Entry.Stack = StackSkip("", log.callerSkip+callerSkipOffset).String
|
327
|
-
}
|
328
|
-
|
329
|
-
return ce
|
330
|
-
}
|
331
|
-
|
332
|
-
// getCallerFrame gets caller frame. The argument skip is the number of stack
|
333
|
-
// frames to ascend, with 0 identifying the caller of getCallerFrame. The
|
334
|
-
// boolean ok is false if it was not possible to recover the information.
|
335
|
-
//
|
336
|
-
// Note: This implementation is similar to runtime.Caller, but it returns the whole frame.
|
337
|
-
func getCallerFrame(skip int) (frame runtime.Frame, ok bool) {
|
338
|
-
const skipOffset = 2 // skip getCallerFrame and Callers
|
339
|
-
|
340
|
-
pc := make([]uintptr, 1)
|
341
|
-
numFrames := runtime.Callers(skip+skipOffset, pc)
|
342
|
-
if numFrames < 1 {
|
343
|
-
return
|
344
|
-
}
|
345
|
-
|
346
|
-
frame, _ = runtime.CallersFrames(pc).Next()
|
347
|
-
return frame, frame.PC != 0
|
348
|
-
}
|
@@ -1,148 +0,0 @@
|
|
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 zap
|
22
|
-
|
23
|
-
import (
|
24
|
-
"fmt"
|
25
|
-
|
26
|
-
"go.uber.org/zap/zapcore"
|
27
|
-
)
|
28
|
-
|
29
|
-
// An Option configures a Logger.
|
30
|
-
type Option interface {
|
31
|
-
apply(*Logger)
|
32
|
-
}
|
33
|
-
|
34
|
-
// optionFunc wraps a func so it satisfies the Option interface.
|
35
|
-
type optionFunc func(*Logger)
|
36
|
-
|
37
|
-
func (f optionFunc) apply(log *Logger) {
|
38
|
-
f(log)
|
39
|
-
}
|
40
|
-
|
41
|
-
// WrapCore wraps or replaces the Logger's underlying zapcore.Core.
|
42
|
-
func WrapCore(f func(zapcore.Core) zapcore.Core) Option {
|
43
|
-
return optionFunc(func(log *Logger) {
|
44
|
-
log.core = f(log.core)
|
45
|
-
})
|
46
|
-
}
|
47
|
-
|
48
|
-
// Hooks registers functions which will be called each time the Logger writes
|
49
|
-
// out an Entry. Repeated use of Hooks is additive.
|
50
|
-
//
|
51
|
-
// Hooks are useful for simple side effects, like capturing metrics for the
|
52
|
-
// number of emitted logs. More complex side effects, including anything that
|
53
|
-
// requires access to the Entry's structured fields, should be implemented as
|
54
|
-
// a zapcore.Core instead. See zapcore.RegisterHooks for details.
|
55
|
-
func Hooks(hooks ...func(zapcore.Entry) error) Option {
|
56
|
-
return optionFunc(func(log *Logger) {
|
57
|
-
log.core = zapcore.RegisterHooks(log.core, hooks...)
|
58
|
-
})
|
59
|
-
}
|
60
|
-
|
61
|
-
// Fields adds fields to the Logger.
|
62
|
-
func Fields(fs ...Field) Option {
|
63
|
-
return optionFunc(func(log *Logger) {
|
64
|
-
log.core = log.core.With(fs)
|
65
|
-
})
|
66
|
-
}
|
67
|
-
|
68
|
-
// ErrorOutput sets the destination for errors generated by the Logger. Note
|
69
|
-
// that this option only affects internal errors; for sample code that sends
|
70
|
-
// error-level logs to a different location from info- and debug-level logs,
|
71
|
-
// see the package-level AdvancedConfiguration example.
|
72
|
-
//
|
73
|
-
// The supplied WriteSyncer must be safe for concurrent use. The Open and
|
74
|
-
// zapcore.Lock functions are the simplest ways to protect files with a mutex.
|
75
|
-
func ErrorOutput(w zapcore.WriteSyncer) Option {
|
76
|
-
return optionFunc(func(log *Logger) {
|
77
|
-
log.errorOutput = w
|
78
|
-
})
|
79
|
-
}
|
80
|
-
|
81
|
-
// Development puts the logger in development mode, which makes DPanic-level
|
82
|
-
// logs panic instead of simply logging an error.
|
83
|
-
func Development() Option {
|
84
|
-
return optionFunc(func(log *Logger) {
|
85
|
-
log.development = true
|
86
|
-
})
|
87
|
-
}
|
88
|
-
|
89
|
-
// AddCaller configures the Logger to annotate each message with the filename,
|
90
|
-
// line number, and function name of zap's caller. See also WithCaller.
|
91
|
-
func AddCaller() Option {
|
92
|
-
return WithCaller(true)
|
93
|
-
}
|
94
|
-
|
95
|
-
// WithCaller configures the Logger to annotate each message with the filename,
|
96
|
-
// line number, and function name of zap's caller, or not, depending on the
|
97
|
-
// value of enabled. This is a generalized form of AddCaller.
|
98
|
-
func WithCaller(enabled bool) Option {
|
99
|
-
return optionFunc(func(log *Logger) {
|
100
|
-
log.addCaller = enabled
|
101
|
-
})
|
102
|
-
}
|
103
|
-
|
104
|
-
// AddCallerSkip increases the number of callers skipped by caller annotation
|
105
|
-
// (as enabled by the AddCaller option). When building wrappers around the
|
106
|
-
// Logger and SugaredLogger, supplying this Option prevents zap from always
|
107
|
-
// reporting the wrapper code as the caller.
|
108
|
-
func AddCallerSkip(skip int) Option {
|
109
|
-
return optionFunc(func(log *Logger) {
|
110
|
-
log.callerSkip += skip
|
111
|
-
})
|
112
|
-
}
|
113
|
-
|
114
|
-
// AddStacktrace configures the Logger to record a stack trace for all messages at
|
115
|
-
// or above a given level.
|
116
|
-
func AddStacktrace(lvl zapcore.LevelEnabler) Option {
|
117
|
-
return optionFunc(func(log *Logger) {
|
118
|
-
log.addStack = lvl
|
119
|
-
})
|
120
|
-
}
|
121
|
-
|
122
|
-
// IncreaseLevel increase the level of the logger. It has no effect if
|
123
|
-
// the passed in level tries to decrease the level of the logger.
|
124
|
-
func IncreaseLevel(lvl zapcore.LevelEnabler) Option {
|
125
|
-
return optionFunc(func(log *Logger) {
|
126
|
-
core, err := zapcore.NewIncreaseLevelCore(log.core, lvl)
|
127
|
-
if err != nil {
|
128
|
-
fmt.Fprintf(log.errorOutput, "failed to IncreaseLevel: %v\n", err)
|
129
|
-
} else {
|
130
|
-
log.core = core
|
131
|
-
}
|
132
|
-
})
|
133
|
-
}
|
134
|
-
|
135
|
-
// OnFatal sets the action to take on fatal logs.
|
136
|
-
func OnFatal(action zapcore.CheckWriteAction) Option {
|
137
|
-
return optionFunc(func(log *Logger) {
|
138
|
-
log.onFatal = action
|
139
|
-
})
|
140
|
-
}
|
141
|
-
|
142
|
-
// WithClock specifies the clock used by the logger to determine the current
|
143
|
-
// time for logged entries. Defaults to the system clock with time.Now.
|
144
|
-
func WithClock(clock zapcore.Clock) Option {
|
145
|
-
return optionFunc(func(log *Logger) {
|
146
|
-
log.clock = clock
|
147
|
-
})
|
148
|
-
}
|