planetscale 0.2.0 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (365) hide show
  1. checksums.yaml +4 -4
  2. data/.buildkite/pipeline.yml +21 -0
  3. data/.github/workflows/ci.yml +9 -1
  4. data/.github/workflows/gem-push.yml +9 -2
  5. data/.licenses/go/github.com/matoous/go-nanoid/v2.dep.yml +34 -0
  6. data/.licenses/go/github.com/planetscale/planetscale-go/planetscale.dep.yml +56 -3
  7. data/.licenses/go/github.com/planetscale/sql-proxy/proxy.dep.yml +205 -172
  8. data/.licenses/go/go.uber.org/zap/buffer.dep.yml +1 -1
  9. data/.licenses/go/go.uber.org/zap/internal/bufferpool.dep.yml +1 -1
  10. data/.licenses/go/go.uber.org/zap/internal/color.dep.yml +1 -1
  11. data/.licenses/go/go.uber.org/zap/internal/exit.dep.yml +1 -1
  12. data/.licenses/go/go.uber.org/zap/zapcore.dep.yml +1 -1
  13. data/.licenses/go/go.uber.org/zap.dep.yml +1 -1
  14. data/README.md +11 -8
  15. data/controller.go +24 -26
  16. data/go.mod +4 -3
  17. data/go.sum +42 -27
  18. data/lib/generators/planetscale/install_generator.rb +8 -6
  19. data/lib/planetscale/version.rb +1 -1
  20. data/lib/planetscale.rb +14 -15
  21. data/planetscale.gemspec +2 -2
  22. data/proxy/planetscale-darwin.h +1 -1
  23. data/proxy/planetscale-darwin.so +0 -0
  24. data/proxy/planetscale-linux.h +1 -1
  25. data/proxy/planetscale-linux.so +0 -0
  26. data/proxy.go +1 -5
  27. metadata +6 -342
  28. data/vendor/github.com/armon/circbuf/.gitignore +0 -22
  29. data/vendor/github.com/armon/circbuf/LICENSE +0 -20
  30. data/vendor/github.com/armon/circbuf/README.md +0 -28
  31. data/vendor/github.com/armon/circbuf/circbuf.go +0 -92
  32. data/vendor/github.com/armon/circbuf/go.mod +0 -1
  33. data/vendor/github.com/golang/protobuf/AUTHORS +0 -3
  34. data/vendor/github.com/golang/protobuf/CONTRIBUTORS +0 -3
  35. data/vendor/github.com/golang/protobuf/LICENSE +0 -28
  36. data/vendor/github.com/golang/protobuf/proto/buffer.go +0 -324
  37. data/vendor/github.com/golang/protobuf/proto/defaults.go +0 -63
  38. data/vendor/github.com/golang/protobuf/proto/deprecated.go +0 -113
  39. data/vendor/github.com/golang/protobuf/proto/discard.go +0 -58
  40. data/vendor/github.com/golang/protobuf/proto/extensions.go +0 -356
  41. data/vendor/github.com/golang/protobuf/proto/properties.go +0 -306
  42. data/vendor/github.com/golang/protobuf/proto/proto.go +0 -167
  43. data/vendor/github.com/golang/protobuf/proto/registry.go +0 -317
  44. data/vendor/github.com/golang/protobuf/proto/text_decode.go +0 -801
  45. data/vendor/github.com/golang/protobuf/proto/text_encode.go +0 -560
  46. data/vendor/github.com/golang/protobuf/proto/wire.go +0 -78
  47. data/vendor/github.com/golang/protobuf/proto/wrappers.go +0 -34
  48. data/vendor/github.com/gorilla/mux/AUTHORS +0 -8
  49. data/vendor/github.com/gorilla/mux/LICENSE +0 -27
  50. data/vendor/github.com/gorilla/mux/README.md +0 -805
  51. data/vendor/github.com/gorilla/mux/doc.go +0 -306
  52. data/vendor/github.com/gorilla/mux/go.mod +0 -3
  53. data/vendor/github.com/gorilla/mux/middleware.go +0 -74
  54. data/vendor/github.com/gorilla/mux/mux.go +0 -606
  55. data/vendor/github.com/gorilla/mux/regexp.go +0 -388
  56. data/vendor/github.com/gorilla/mux/route.go +0 -736
  57. data/vendor/github.com/gorilla/mux/test_helpers.go +0 -19
  58. data/vendor/github.com/hashicorp/go-cleanhttp/LICENSE +0 -363
  59. data/vendor/github.com/hashicorp/go-cleanhttp/README.md +0 -30
  60. data/vendor/github.com/hashicorp/go-cleanhttp/cleanhttp.go +0 -58
  61. data/vendor/github.com/hashicorp/go-cleanhttp/doc.go +0 -20
  62. data/vendor/github.com/hashicorp/go-cleanhttp/go.mod +0 -3
  63. data/vendor/github.com/hashicorp/go-cleanhttp/handlers.go +0 -48
  64. data/vendor/github.com/mitchellh/go-homedir/LICENSE +0 -21
  65. data/vendor/github.com/mitchellh/go-homedir/README.md +0 -14
  66. data/vendor/github.com/mitchellh/go-homedir/go.mod +0 -1
  67. data/vendor/github.com/mitchellh/go-homedir/homedir.go +0 -167
  68. data/vendor/github.com/pkg/errors/.gitignore +0 -24
  69. data/vendor/github.com/pkg/errors/.travis.yml +0 -10
  70. data/vendor/github.com/pkg/errors/LICENSE +0 -23
  71. data/vendor/github.com/pkg/errors/Makefile +0 -44
  72. data/vendor/github.com/pkg/errors/README.md +0 -59
  73. data/vendor/github.com/pkg/errors/appveyor.yml +0 -32
  74. data/vendor/github.com/pkg/errors/errors.go +0 -288
  75. data/vendor/github.com/pkg/errors/go113.go +0 -38
  76. data/vendor/github.com/pkg/errors/stack.go +0 -177
  77. data/vendor/github.com/planetscale/planetscale-go/planetscale/backups.go +0 -139
  78. data/vendor/github.com/planetscale/planetscale-go/planetscale/branches.go +0 -258
  79. data/vendor/github.com/planetscale/planetscale-go/planetscale/certs.go +0 -142
  80. data/vendor/github.com/planetscale/planetscale-go/planetscale/client.go +0 -305
  81. data/vendor/github.com/planetscale/planetscale-go/planetscale/databases.go +0 -131
  82. data/vendor/github.com/planetscale/planetscale-go/planetscale/deploy_requests.go +0 -368
  83. data/vendor/github.com/planetscale/planetscale-go/planetscale/organizations.go +0 -78
  84. data/vendor/github.com/planetscale/planetscale-go/planetscale/service_tokens.go +0 -163
  85. data/vendor/github.com/planetscale/sql-proxy/proxy/client.go +0 -467
  86. data/vendor/github.com/planetscale/sql-proxy/proxy/tls_cache.go +0 -73
  87. data/vendor/go.uber.org/atomic/.codecov.yml +0 -19
  88. data/vendor/go.uber.org/atomic/.gitignore +0 -12
  89. data/vendor/go.uber.org/atomic/.travis.yml +0 -27
  90. data/vendor/go.uber.org/atomic/CHANGELOG.md +0 -76
  91. data/vendor/go.uber.org/atomic/LICENSE.txt +0 -19
  92. data/vendor/go.uber.org/atomic/Makefile +0 -78
  93. data/vendor/go.uber.org/atomic/README.md +0 -63
  94. data/vendor/go.uber.org/atomic/bool.go +0 -81
  95. data/vendor/go.uber.org/atomic/bool_ext.go +0 -53
  96. data/vendor/go.uber.org/atomic/doc.go +0 -23
  97. data/vendor/go.uber.org/atomic/duration.go +0 -82
  98. data/vendor/go.uber.org/atomic/duration_ext.go +0 -40
  99. data/vendor/go.uber.org/atomic/error.go +0 -51
  100. data/vendor/go.uber.org/atomic/error_ext.go +0 -39
  101. data/vendor/go.uber.org/atomic/float64.go +0 -76
  102. data/vendor/go.uber.org/atomic/float64_ext.go +0 -47
  103. data/vendor/go.uber.org/atomic/gen.go +0 -26
  104. data/vendor/go.uber.org/atomic/go.mod +0 -8
  105. data/vendor/go.uber.org/atomic/go.sum +0 -9
  106. data/vendor/go.uber.org/atomic/int32.go +0 -102
  107. data/vendor/go.uber.org/atomic/int64.go +0 -102
  108. data/vendor/go.uber.org/atomic/nocmp.go +0 -35
  109. data/vendor/go.uber.org/atomic/string.go +0 -54
  110. data/vendor/go.uber.org/atomic/string_ext.go +0 -43
  111. data/vendor/go.uber.org/atomic/uint32.go +0 -102
  112. data/vendor/go.uber.org/atomic/uint64.go +0 -102
  113. data/vendor/go.uber.org/atomic/value.go +0 -31
  114. data/vendor/go.uber.org/multierr/.codecov.yml +0 -15
  115. data/vendor/go.uber.org/multierr/.gitignore +0 -4
  116. data/vendor/go.uber.org/multierr/.travis.yml +0 -23
  117. data/vendor/go.uber.org/multierr/CHANGELOG.md +0 -60
  118. data/vendor/go.uber.org/multierr/LICENSE.txt +0 -19
  119. data/vendor/go.uber.org/multierr/Makefile +0 -42
  120. data/vendor/go.uber.org/multierr/README.md +0 -23
  121. data/vendor/go.uber.org/multierr/error.go +0 -449
  122. data/vendor/go.uber.org/multierr/glide.yaml +0 -8
  123. data/vendor/go.uber.org/multierr/go.mod +0 -8
  124. data/vendor/go.uber.org/multierr/go.sum +0 -11
  125. data/vendor/go.uber.org/multierr/go113.go +0 -52
  126. data/vendor/go.uber.org/zap/.codecov.yml +0 -17
  127. data/vendor/go.uber.org/zap/.gitignore +0 -32
  128. data/vendor/go.uber.org/zap/.readme.tmpl +0 -109
  129. data/vendor/go.uber.org/zap/.travis.yml +0 -23
  130. data/vendor/go.uber.org/zap/CHANGELOG.md +0 -432
  131. data/vendor/go.uber.org/zap/CODE_OF_CONDUCT.md +0 -75
  132. data/vendor/go.uber.org/zap/CONTRIBUTING.md +0 -81
  133. data/vendor/go.uber.org/zap/FAQ.md +0 -156
  134. data/vendor/go.uber.org/zap/LICENSE.txt +0 -19
  135. data/vendor/go.uber.org/zap/Makefile +0 -63
  136. data/vendor/go.uber.org/zap/README.md +0 -134
  137. data/vendor/go.uber.org/zap/array.go +0 -320
  138. data/vendor/go.uber.org/zap/buffer/buffer.go +0 -123
  139. data/vendor/go.uber.org/zap/buffer/pool.go +0 -49
  140. data/vendor/go.uber.org/zap/checklicense.sh +0 -17
  141. data/vendor/go.uber.org/zap/config.go +0 -264
  142. data/vendor/go.uber.org/zap/doc.go +0 -113
  143. data/vendor/go.uber.org/zap/encoder.go +0 -79
  144. data/vendor/go.uber.org/zap/error.go +0 -80
  145. data/vendor/go.uber.org/zap/field.go +0 -539
  146. data/vendor/go.uber.org/zap/flag.go +0 -39
  147. data/vendor/go.uber.org/zap/glide.yaml +0 -34
  148. data/vendor/go.uber.org/zap/global.go +0 -168
  149. data/vendor/go.uber.org/zap/global_go112.go +0 -26
  150. data/vendor/go.uber.org/zap/global_prego112.go +0 -26
  151. data/vendor/go.uber.org/zap/go.mod +0 -13
  152. data/vendor/go.uber.org/zap/go.sum +0 -56
  153. data/vendor/go.uber.org/zap/http_handler.go +0 -81
  154. data/vendor/go.uber.org/zap/internal/bufferpool/bufferpool.go +0 -31
  155. data/vendor/go.uber.org/zap/internal/color/color.go +0 -44
  156. data/vendor/go.uber.org/zap/internal/exit/exit.go +0 -64
  157. data/vendor/go.uber.org/zap/level.go +0 -132
  158. data/vendor/go.uber.org/zap/logger.go +0 -344
  159. data/vendor/go.uber.org/zap/options.go +0 -140
  160. data/vendor/go.uber.org/zap/sink.go +0 -161
  161. data/vendor/go.uber.org/zap/stacktrace.go +0 -85
  162. data/vendor/go.uber.org/zap/sugar.go +0 -304
  163. data/vendor/go.uber.org/zap/time.go +0 -27
  164. data/vendor/go.uber.org/zap/writer.go +0 -99
  165. data/vendor/go.uber.org/zap/zapcore/console_encoder.go +0 -161
  166. data/vendor/go.uber.org/zap/zapcore/core.go +0 -113
  167. data/vendor/go.uber.org/zap/zapcore/doc.go +0 -24
  168. data/vendor/go.uber.org/zap/zapcore/encoder.go +0 -443
  169. data/vendor/go.uber.org/zap/zapcore/entry.go +0 -264
  170. data/vendor/go.uber.org/zap/zapcore/error.go +0 -115
  171. data/vendor/go.uber.org/zap/zapcore/field.go +0 -227
  172. data/vendor/go.uber.org/zap/zapcore/hook.go +0 -68
  173. data/vendor/go.uber.org/zap/zapcore/increase_level.go +0 -66
  174. data/vendor/go.uber.org/zap/zapcore/json_encoder.go +0 -534
  175. data/vendor/go.uber.org/zap/zapcore/level.go +0 -175
  176. data/vendor/go.uber.org/zap/zapcore/level_strings.go +0 -46
  177. data/vendor/go.uber.org/zap/zapcore/marshaler.go +0 -61
  178. data/vendor/go.uber.org/zap/zapcore/memory_encoder.go +0 -179
  179. data/vendor/go.uber.org/zap/zapcore/sampler.go +0 -208
  180. data/vendor/go.uber.org/zap/zapcore/tee.go +0 -81
  181. data/vendor/go.uber.org/zap/zapcore/write_syncer.go +0 -123
  182. data/vendor/golang.org/x/net/AUTHORS +0 -3
  183. data/vendor/golang.org/x/net/CONTRIBUTORS +0 -3
  184. data/vendor/golang.org/x/net/LICENSE +0 -27
  185. data/vendor/golang.org/x/net/PATENTS +0 -22
  186. data/vendor/golang.org/x/net/context/context.go +0 -56
  187. data/vendor/golang.org/x/net/context/ctxhttp/ctxhttp.go +0 -71
  188. data/vendor/golang.org/x/net/context/go17.go +0 -73
  189. data/vendor/golang.org/x/net/context/go19.go +0 -21
  190. data/vendor/golang.org/x/net/context/pre_go17.go +0 -301
  191. data/vendor/golang.org/x/net/context/pre_go19.go +0 -110
  192. data/vendor/golang.org/x/oauth2/.travis.yml +0 -13
  193. data/vendor/golang.org/x/oauth2/AUTHORS +0 -3
  194. data/vendor/golang.org/x/oauth2/CONTRIBUTING.md +0 -26
  195. data/vendor/golang.org/x/oauth2/CONTRIBUTORS +0 -3
  196. data/vendor/golang.org/x/oauth2/LICENSE +0 -27
  197. data/vendor/golang.org/x/oauth2/README.md +0 -36
  198. data/vendor/golang.org/x/oauth2/go.mod +0 -9
  199. data/vendor/golang.org/x/oauth2/go.sum +0 -361
  200. data/vendor/golang.org/x/oauth2/internal/client_appengine.go +0 -14
  201. data/vendor/golang.org/x/oauth2/internal/doc.go +0 -6
  202. data/vendor/golang.org/x/oauth2/internal/oauth2.go +0 -37
  203. data/vendor/golang.org/x/oauth2/internal/token.go +0 -294
  204. data/vendor/golang.org/x/oauth2/internal/transport.go +0 -33
  205. data/vendor/golang.org/x/oauth2/oauth2.go +0 -381
  206. data/vendor/golang.org/x/oauth2/token.go +0 -178
  207. data/vendor/golang.org/x/oauth2/transport.go +0 -89
  208. data/vendor/google.golang.org/appengine/LICENSE +0 -202
  209. data/vendor/google.golang.org/appengine/internal/api.go +0 -678
  210. data/vendor/google.golang.org/appengine/internal/api_classic.go +0 -169
  211. data/vendor/google.golang.org/appengine/internal/api_common.go +0 -123
  212. data/vendor/google.golang.org/appengine/internal/app_id.go +0 -28
  213. data/vendor/google.golang.org/appengine/internal/base/api_base.pb.go +0 -308
  214. data/vendor/google.golang.org/appengine/internal/base/api_base.proto +0 -33
  215. data/vendor/google.golang.org/appengine/internal/datastore/datastore_v3.pb.go +0 -4367
  216. data/vendor/google.golang.org/appengine/internal/datastore/datastore_v3.proto +0 -551
  217. data/vendor/google.golang.org/appengine/internal/identity.go +0 -55
  218. data/vendor/google.golang.org/appengine/internal/identity_classic.go +0 -61
  219. data/vendor/google.golang.org/appengine/internal/identity_flex.go +0 -11
  220. data/vendor/google.golang.org/appengine/internal/identity_vm.go +0 -134
  221. data/vendor/google.golang.org/appengine/internal/internal.go +0 -110
  222. data/vendor/google.golang.org/appengine/internal/log/log_service.pb.go +0 -1313
  223. data/vendor/google.golang.org/appengine/internal/log/log_service.proto +0 -150
  224. data/vendor/google.golang.org/appengine/internal/main.go +0 -16
  225. data/vendor/google.golang.org/appengine/internal/main_common.go +0 -7
  226. data/vendor/google.golang.org/appengine/internal/main_vm.go +0 -69
  227. data/vendor/google.golang.org/appengine/internal/metadata.go +0 -60
  228. data/vendor/google.golang.org/appengine/internal/net.go +0 -56
  229. data/vendor/google.golang.org/appengine/internal/regen.sh +0 -40
  230. data/vendor/google.golang.org/appengine/internal/remote_api/remote_api.pb.go +0 -361
  231. data/vendor/google.golang.org/appengine/internal/remote_api/remote_api.proto +0 -44
  232. data/vendor/google.golang.org/appengine/internal/transaction.go +0 -115
  233. data/vendor/google.golang.org/appengine/internal/urlfetch/urlfetch_service.pb.go +0 -527
  234. data/vendor/google.golang.org/appengine/internal/urlfetch/urlfetch_service.proto +0 -64
  235. data/vendor/google.golang.org/appengine/urlfetch/urlfetch.go +0 -210
  236. data/vendor/google.golang.org/protobuf/AUTHORS +0 -3
  237. data/vendor/google.golang.org/protobuf/CONTRIBUTORS +0 -3
  238. data/vendor/google.golang.org/protobuf/LICENSE +0 -27
  239. data/vendor/google.golang.org/protobuf/PATENTS +0 -22
  240. data/vendor/google.golang.org/protobuf/encoding/prototext/decode.go +0 -773
  241. data/vendor/google.golang.org/protobuf/encoding/prototext/doc.go +0 -7
  242. data/vendor/google.golang.org/protobuf/encoding/prototext/encode.go +0 -371
  243. data/vendor/google.golang.org/protobuf/encoding/protowire/wire.go +0 -538
  244. data/vendor/google.golang.org/protobuf/internal/descfmt/stringer.go +0 -318
  245. data/vendor/google.golang.org/protobuf/internal/descopts/options.go +0 -29
  246. data/vendor/google.golang.org/protobuf/internal/detrand/rand.go +0 -69
  247. data/vendor/google.golang.org/protobuf/internal/encoding/defval/default.go +0 -213
  248. data/vendor/google.golang.org/protobuf/internal/encoding/messageset/messageset.go +0 -241
  249. data/vendor/google.golang.org/protobuf/internal/encoding/tag/tag.go +0 -207
  250. data/vendor/google.golang.org/protobuf/internal/encoding/text/decode.go +0 -665
  251. data/vendor/google.golang.org/protobuf/internal/encoding/text/decode_number.go +0 -190
  252. data/vendor/google.golang.org/protobuf/internal/encoding/text/decode_string.go +0 -161
  253. data/vendor/google.golang.org/protobuf/internal/encoding/text/decode_token.go +0 -373
  254. data/vendor/google.golang.org/protobuf/internal/encoding/text/doc.go +0 -29
  255. data/vendor/google.golang.org/protobuf/internal/encoding/text/encode.go +0 -265
  256. data/vendor/google.golang.org/protobuf/internal/errors/errors.go +0 -89
  257. data/vendor/google.golang.org/protobuf/internal/errors/is_go112.go +0 -39
  258. data/vendor/google.golang.org/protobuf/internal/errors/is_go113.go +0 -12
  259. data/vendor/google.golang.org/protobuf/internal/filedesc/build.go +0 -158
  260. data/vendor/google.golang.org/protobuf/internal/filedesc/desc.go +0 -631
  261. data/vendor/google.golang.org/protobuf/internal/filedesc/desc_init.go +0 -471
  262. data/vendor/google.golang.org/protobuf/internal/filedesc/desc_lazy.go +0 -704
  263. data/vendor/google.golang.org/protobuf/internal/filedesc/desc_list.go +0 -450
  264. data/vendor/google.golang.org/protobuf/internal/filedesc/desc_list_gen.go +0 -356
  265. data/vendor/google.golang.org/protobuf/internal/filedesc/placeholder.go +0 -107
  266. data/vendor/google.golang.org/protobuf/internal/filetype/build.go +0 -297
  267. data/vendor/google.golang.org/protobuf/internal/flags/flags.go +0 -24
  268. data/vendor/google.golang.org/protobuf/internal/flags/proto_legacy_disable.go +0 -9
  269. data/vendor/google.golang.org/protobuf/internal/flags/proto_legacy_enable.go +0 -9
  270. data/vendor/google.golang.org/protobuf/internal/genid/any_gen.go +0 -34
  271. data/vendor/google.golang.org/protobuf/internal/genid/api_gen.go +0 -106
  272. data/vendor/google.golang.org/protobuf/internal/genid/descriptor_gen.go +0 -829
  273. data/vendor/google.golang.org/protobuf/internal/genid/doc.go +0 -11
  274. data/vendor/google.golang.org/protobuf/internal/genid/duration_gen.go +0 -34
  275. data/vendor/google.golang.org/protobuf/internal/genid/empty_gen.go +0 -19
  276. data/vendor/google.golang.org/protobuf/internal/genid/field_mask_gen.go +0 -31
  277. data/vendor/google.golang.org/protobuf/internal/genid/goname.go +0 -25
  278. data/vendor/google.golang.org/protobuf/internal/genid/map_entry.go +0 -16
  279. data/vendor/google.golang.org/protobuf/internal/genid/source_context_gen.go +0 -31
  280. data/vendor/google.golang.org/protobuf/internal/genid/struct_gen.go +0 -116
  281. data/vendor/google.golang.org/protobuf/internal/genid/timestamp_gen.go +0 -34
  282. data/vendor/google.golang.org/protobuf/internal/genid/type_gen.go +0 -184
  283. data/vendor/google.golang.org/protobuf/internal/genid/wrappers.go +0 -13
  284. data/vendor/google.golang.org/protobuf/internal/genid/wrappers_gen.go +0 -175
  285. data/vendor/google.golang.org/protobuf/internal/impl/api_export.go +0 -177
  286. data/vendor/google.golang.org/protobuf/internal/impl/checkinit.go +0 -141
  287. data/vendor/google.golang.org/protobuf/internal/impl/codec_extension.go +0 -223
  288. data/vendor/google.golang.org/protobuf/internal/impl/codec_field.go +0 -830
  289. data/vendor/google.golang.org/protobuf/internal/impl/codec_gen.go +0 -5637
  290. data/vendor/google.golang.org/protobuf/internal/impl/codec_map.go +0 -388
  291. data/vendor/google.golang.org/protobuf/internal/impl/codec_map_go111.go +0 -37
  292. data/vendor/google.golang.org/protobuf/internal/impl/codec_map_go112.go +0 -11
  293. data/vendor/google.golang.org/protobuf/internal/impl/codec_message.go +0 -217
  294. data/vendor/google.golang.org/protobuf/internal/impl/codec_messageset.go +0 -123
  295. data/vendor/google.golang.org/protobuf/internal/impl/codec_reflect.go +0 -209
  296. data/vendor/google.golang.org/protobuf/internal/impl/codec_tables.go +0 -557
  297. data/vendor/google.golang.org/protobuf/internal/impl/codec_unsafe.go +0 -17
  298. data/vendor/google.golang.org/protobuf/internal/impl/convert.go +0 -496
  299. data/vendor/google.golang.org/protobuf/internal/impl/convert_list.go +0 -141
  300. data/vendor/google.golang.org/protobuf/internal/impl/convert_map.go +0 -121
  301. data/vendor/google.golang.org/protobuf/internal/impl/decode.go +0 -276
  302. data/vendor/google.golang.org/protobuf/internal/impl/encode.go +0 -201
  303. data/vendor/google.golang.org/protobuf/internal/impl/enum.go +0 -21
  304. data/vendor/google.golang.org/protobuf/internal/impl/extension.go +0 -156
  305. data/vendor/google.golang.org/protobuf/internal/impl/legacy_enum.go +0 -219
  306. data/vendor/google.golang.org/protobuf/internal/impl/legacy_export.go +0 -92
  307. data/vendor/google.golang.org/protobuf/internal/impl/legacy_extension.go +0 -176
  308. data/vendor/google.golang.org/protobuf/internal/impl/legacy_file.go +0 -81
  309. data/vendor/google.golang.org/protobuf/internal/impl/legacy_message.go +0 -558
  310. data/vendor/google.golang.org/protobuf/internal/impl/merge.go +0 -176
  311. data/vendor/google.golang.org/protobuf/internal/impl/merge_gen.go +0 -209
  312. data/vendor/google.golang.org/protobuf/internal/impl/message.go +0 -276
  313. data/vendor/google.golang.org/protobuf/internal/impl/message_reflect.go +0 -465
  314. data/vendor/google.golang.org/protobuf/internal/impl/message_reflect_field.go +0 -543
  315. data/vendor/google.golang.org/protobuf/internal/impl/message_reflect_gen.go +0 -249
  316. data/vendor/google.golang.org/protobuf/internal/impl/pointer_reflect.go +0 -178
  317. data/vendor/google.golang.org/protobuf/internal/impl/pointer_unsafe.go +0 -174
  318. data/vendor/google.golang.org/protobuf/internal/impl/validate.go +0 -576
  319. data/vendor/google.golang.org/protobuf/internal/impl/weak.go +0 -74
  320. data/vendor/google.golang.org/protobuf/internal/order/order.go +0 -89
  321. data/vendor/google.golang.org/protobuf/internal/order/range.go +0 -115
  322. data/vendor/google.golang.org/protobuf/internal/pragma/pragma.go +0 -29
  323. data/vendor/google.golang.org/protobuf/internal/set/ints.go +0 -58
  324. data/vendor/google.golang.org/protobuf/internal/strs/strings.go +0 -196
  325. data/vendor/google.golang.org/protobuf/internal/strs/strings_pure.go +0 -27
  326. data/vendor/google.golang.org/protobuf/internal/strs/strings_unsafe.go +0 -94
  327. data/vendor/google.golang.org/protobuf/internal/version/version.go +0 -79
  328. data/vendor/google.golang.org/protobuf/proto/checkinit.go +0 -71
  329. data/vendor/google.golang.org/protobuf/proto/decode.go +0 -278
  330. data/vendor/google.golang.org/protobuf/proto/decode_gen.go +0 -603
  331. data/vendor/google.golang.org/protobuf/proto/doc.go +0 -94
  332. data/vendor/google.golang.org/protobuf/proto/encode.go +0 -319
  333. data/vendor/google.golang.org/protobuf/proto/encode_gen.go +0 -97
  334. data/vendor/google.golang.org/protobuf/proto/equal.go +0 -167
  335. data/vendor/google.golang.org/protobuf/proto/extension.go +0 -92
  336. data/vendor/google.golang.org/protobuf/proto/merge.go +0 -139
  337. data/vendor/google.golang.org/protobuf/proto/messageset.go +0 -93
  338. data/vendor/google.golang.org/protobuf/proto/proto.go +0 -43
  339. data/vendor/google.golang.org/protobuf/proto/proto_methods.go +0 -19
  340. data/vendor/google.golang.org/protobuf/proto/proto_reflect.go +0 -19
  341. data/vendor/google.golang.org/protobuf/proto/reset.go +0 -43
  342. data/vendor/google.golang.org/protobuf/proto/size.go +0 -97
  343. data/vendor/google.golang.org/protobuf/proto/size_gen.go +0 -55
  344. data/vendor/google.golang.org/protobuf/proto/wrappers.go +0 -29
  345. data/vendor/google.golang.org/protobuf/reflect/protodesc/desc.go +0 -276
  346. data/vendor/google.golang.org/protobuf/reflect/protodesc/desc_init.go +0 -248
  347. data/vendor/google.golang.org/protobuf/reflect/protodesc/desc_resolve.go +0 -286
  348. data/vendor/google.golang.org/protobuf/reflect/protodesc/desc_validate.go +0 -374
  349. data/vendor/google.golang.org/protobuf/reflect/protodesc/proto.go +0 -252
  350. data/vendor/google.golang.org/protobuf/reflect/protoreflect/methods.go +0 -77
  351. data/vendor/google.golang.org/protobuf/reflect/protoreflect/proto.go +0 -504
  352. data/vendor/google.golang.org/protobuf/reflect/protoreflect/source.go +0 -128
  353. data/vendor/google.golang.org/protobuf/reflect/protoreflect/source_gen.go +0 -461
  354. data/vendor/google.golang.org/protobuf/reflect/protoreflect/type.go +0 -665
  355. data/vendor/google.golang.org/protobuf/reflect/protoreflect/value.go +0 -285
  356. data/vendor/google.golang.org/protobuf/reflect/protoreflect/value_pure.go +0 -59
  357. data/vendor/google.golang.org/protobuf/reflect/protoreflect/value_union.go +0 -411
  358. data/vendor/google.golang.org/protobuf/reflect/protoreflect/value_unsafe.go +0 -98
  359. data/vendor/google.golang.org/protobuf/reflect/protoregistry/registry.go +0 -869
  360. data/vendor/google.golang.org/protobuf/runtime/protoiface/legacy.go +0 -15
  361. data/vendor/google.golang.org/protobuf/runtime/protoiface/methods.go +0 -167
  362. data/vendor/google.golang.org/protobuf/runtime/protoimpl/impl.go +0 -44
  363. data/vendor/google.golang.org/protobuf/runtime/protoimpl/version.go +0 -56
  364. data/vendor/google.golang.org/protobuf/types/descriptorpb/descriptor.pb.go +0 -4039
  365. data/vendor/modules.txt +0 -79
@@ -1,344 +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
- "time"
30
-
31
- "go.uber.org/zap/zapcore"
32
- )
33
-
34
- // A Logger provides fast, leveled, structured logging. All methods are safe
35
- // for concurrent use.
36
- //
37
- // The Logger is designed for contexts in which every microsecond and every
38
- // allocation matters, so its API intentionally favors performance and type
39
- // safety over brevity. For most applications, the SugaredLogger strikes a
40
- // better balance between performance and ergonomics.
41
- type Logger struct {
42
- core zapcore.Core
43
-
44
- development bool
45
- name string
46
- errorOutput zapcore.WriteSyncer
47
-
48
- addCaller bool
49
- addStack zapcore.LevelEnabler
50
-
51
- callerSkip int
52
- onFatal zapcore.CheckWriteAction // default is WriteThenFatal
53
- }
54
-
55
- // New constructs a new Logger from the provided zapcore.Core and Options. If
56
- // the passed zapcore.Core is nil, it falls back to using a no-op
57
- // implementation.
58
- //
59
- // This is the most flexible way to construct a Logger, but also the most
60
- // verbose. For typical use cases, the highly-opinionated presets
61
- // (NewProduction, NewDevelopment, and NewExample) or the Config struct are
62
- // more convenient.
63
- //
64
- // For sample code, see the package-level AdvancedConfiguration example.
65
- func New(core zapcore.Core, options ...Option) *Logger {
66
- if core == nil {
67
- return NewNop()
68
- }
69
- log := &Logger{
70
- core: core,
71
- errorOutput: zapcore.Lock(os.Stderr),
72
- addStack: zapcore.FatalLevel + 1,
73
- }
74
- return log.WithOptions(options...)
75
- }
76
-
77
- // NewNop returns a no-op Logger. It never writes out logs or internal errors,
78
- // and it never runs user-defined hooks.
79
- //
80
- // Using WithOptions to replace the Core or error output of a no-op Logger can
81
- // re-enable logging.
82
- func NewNop() *Logger {
83
- return &Logger{
84
- core: zapcore.NewNopCore(),
85
- errorOutput: zapcore.AddSync(ioutil.Discard),
86
- addStack: zapcore.FatalLevel + 1,
87
- }
88
- }
89
-
90
- // NewProduction builds a sensible production Logger that writes InfoLevel and
91
- // above logs to standard error as JSON.
92
- //
93
- // It's a shortcut for NewProductionConfig().Build(...Option).
94
- func NewProduction(options ...Option) (*Logger, error) {
95
- return NewProductionConfig().Build(options...)
96
- }
97
-
98
- // NewDevelopment builds a development Logger that writes DebugLevel and above
99
- // logs to standard error in a human-friendly format.
100
- //
101
- // It's a shortcut for NewDevelopmentConfig().Build(...Option).
102
- func NewDevelopment(options ...Option) (*Logger, error) {
103
- return NewDevelopmentConfig().Build(options...)
104
- }
105
-
106
- // NewExample builds a Logger that's designed for use in zap's testable
107
- // examples. It writes DebugLevel and above logs to standard out as JSON, but
108
- // omits the timestamp and calling function to keep example output
109
- // short and deterministic.
110
- func NewExample(options ...Option) *Logger {
111
- encoderCfg := zapcore.EncoderConfig{
112
- MessageKey: "msg",
113
- LevelKey: "level",
114
- NameKey: "logger",
115
- EncodeLevel: zapcore.LowercaseLevelEncoder,
116
- EncodeTime: zapcore.ISO8601TimeEncoder,
117
- EncodeDuration: zapcore.StringDurationEncoder,
118
- }
119
- core := zapcore.NewCore(zapcore.NewJSONEncoder(encoderCfg), os.Stdout, DebugLevel)
120
- return New(core).WithOptions(options...)
121
- }
122
-
123
- // Sugar wraps the Logger to provide a more ergonomic, but slightly slower,
124
- // API. Sugaring a Logger is quite inexpensive, so it's reasonable for a
125
- // single application to use both Loggers and SugaredLoggers, converting
126
- // between them on the boundaries of performance-sensitive code.
127
- func (log *Logger) Sugar() *SugaredLogger {
128
- core := log.clone()
129
- core.callerSkip += 2
130
- return &SugaredLogger{core}
131
- }
132
-
133
- // Named adds a new path segment to the logger's name. Segments are joined by
134
- // periods. By default, Loggers are unnamed.
135
- func (log *Logger) Named(s string) *Logger {
136
- if s == "" {
137
- return log
138
- }
139
- l := log.clone()
140
- if log.name == "" {
141
- l.name = s
142
- } else {
143
- l.name = strings.Join([]string{l.name, s}, ".")
144
- }
145
- return l
146
- }
147
-
148
- // WithOptions clones the current Logger, applies the supplied Options, and
149
- // returns the resulting Logger. It's safe to use concurrently.
150
- func (log *Logger) WithOptions(opts ...Option) *Logger {
151
- c := log.clone()
152
- for _, opt := range opts {
153
- opt.apply(c)
154
- }
155
- return c
156
- }
157
-
158
- // With creates a child logger and adds structured context to it. Fields added
159
- // to the child don't affect the parent, and vice versa.
160
- func (log *Logger) With(fields ...Field) *Logger {
161
- if len(fields) == 0 {
162
- return log
163
- }
164
- l := log.clone()
165
- l.core = l.core.With(fields)
166
- return l
167
- }
168
-
169
- // Check returns a CheckedEntry if logging a message at the specified level
170
- // is enabled. It's a completely optional optimization; in high-performance
171
- // applications, Check can help avoid allocating a slice to hold fields.
172
- func (log *Logger) Check(lvl zapcore.Level, msg string) *zapcore.CheckedEntry {
173
- return log.check(lvl, msg)
174
- }
175
-
176
- // Debug logs a message at DebugLevel. The message includes any fields passed
177
- // at the log site, as well as any fields accumulated on the logger.
178
- func (log *Logger) Debug(msg string, fields ...Field) {
179
- if ce := log.check(DebugLevel, msg); ce != nil {
180
- ce.Write(fields...)
181
- }
182
- }
183
-
184
- // Info logs a message at InfoLevel. The message includes any fields passed
185
- // at the log site, as well as any fields accumulated on the logger.
186
- func (log *Logger) Info(msg string, fields ...Field) {
187
- if ce := log.check(InfoLevel, msg); ce != nil {
188
- ce.Write(fields...)
189
- }
190
- }
191
-
192
- // Warn logs a message at WarnLevel. The message includes any fields passed
193
- // at the log site, as well as any fields accumulated on the logger.
194
- func (log *Logger) Warn(msg string, fields ...Field) {
195
- if ce := log.check(WarnLevel, msg); ce != nil {
196
- ce.Write(fields...)
197
- }
198
- }
199
-
200
- // Error logs a message at ErrorLevel. The message includes any fields passed
201
- // at the log site, as well as any fields accumulated on the logger.
202
- func (log *Logger) Error(msg string, fields ...Field) {
203
- if ce := log.check(ErrorLevel, msg); ce != nil {
204
- ce.Write(fields...)
205
- }
206
- }
207
-
208
- // DPanic logs a message at DPanicLevel. The message includes any fields
209
- // passed at the log site, as well as any fields accumulated on the logger.
210
- //
211
- // If the logger is in development mode, it then panics (DPanic means
212
- // "development panic"). This is useful for catching errors that are
213
- // recoverable, but shouldn't ever happen.
214
- func (log *Logger) DPanic(msg string, fields ...Field) {
215
- if ce := log.check(DPanicLevel, msg); ce != nil {
216
- ce.Write(fields...)
217
- }
218
- }
219
-
220
- // Panic logs a message at PanicLevel. The message includes any fields passed
221
- // at the log site, as well as any fields accumulated on the logger.
222
- //
223
- // The logger then panics, even if logging at PanicLevel is disabled.
224
- func (log *Logger) Panic(msg string, fields ...Field) {
225
- if ce := log.check(PanicLevel, msg); ce != nil {
226
- ce.Write(fields...)
227
- }
228
- }
229
-
230
- // Fatal logs a message at FatalLevel. The message includes any fields passed
231
- // at the log site, as well as any fields accumulated on the logger.
232
- //
233
- // The logger then calls os.Exit(1), even if logging at FatalLevel is
234
- // disabled.
235
- func (log *Logger) Fatal(msg string, fields ...Field) {
236
- if ce := log.check(FatalLevel, msg); ce != nil {
237
- ce.Write(fields...)
238
- }
239
- }
240
-
241
- // Sync calls the underlying Core's Sync method, flushing any buffered log
242
- // entries. Applications should take care to call Sync before exiting.
243
- func (log *Logger) Sync() error {
244
- return log.core.Sync()
245
- }
246
-
247
- // Core returns the Logger's underlying zapcore.Core.
248
- func (log *Logger) Core() zapcore.Core {
249
- return log.core
250
- }
251
-
252
- func (log *Logger) clone() *Logger {
253
- copy := *log
254
- return &copy
255
- }
256
-
257
- func (log *Logger) check(lvl zapcore.Level, msg string) *zapcore.CheckedEntry {
258
- // check must always be called directly by a method in the Logger interface
259
- // (e.g., Check, Info, Fatal).
260
- const callerSkipOffset = 2
261
-
262
- // Check the level first to reduce the cost of disabled log calls.
263
- // Since Panic and higher may exit, we skip the optimization for those levels.
264
- if lvl < zapcore.DPanicLevel && !log.core.Enabled(lvl) {
265
- return nil
266
- }
267
-
268
- // Create basic checked entry thru the core; this will be non-nil if the
269
- // log message will actually be written somewhere.
270
- ent := zapcore.Entry{
271
- LoggerName: log.name,
272
- Time: time.Now(),
273
- Level: lvl,
274
- Message: msg,
275
- }
276
- ce := log.core.Check(ent, nil)
277
- willWrite := ce != nil
278
-
279
- // Set up any required terminal behavior.
280
- switch ent.Level {
281
- case zapcore.PanicLevel:
282
- ce = ce.Should(ent, zapcore.WriteThenPanic)
283
- case zapcore.FatalLevel:
284
- onFatal := log.onFatal
285
- // Noop is the default value for CheckWriteAction, and it leads to
286
- // continued execution after a Fatal which is unexpected.
287
- if onFatal == zapcore.WriteThenNoop {
288
- onFatal = zapcore.WriteThenFatal
289
- }
290
- ce = ce.Should(ent, onFatal)
291
- case zapcore.DPanicLevel:
292
- if log.development {
293
- ce = ce.Should(ent, zapcore.WriteThenPanic)
294
- }
295
- }
296
-
297
- // Only do further annotation if we're going to write this message; checked
298
- // entries that exist only for terminal behavior don't benefit from
299
- // annotation.
300
- if !willWrite {
301
- return ce
302
- }
303
-
304
- // Thread the error output through to the CheckedEntry.
305
- ce.ErrorOutput = log.errorOutput
306
- if log.addCaller {
307
- frame, defined := getCallerFrame(log.callerSkip + callerSkipOffset)
308
- if !defined {
309
- fmt.Fprintf(log.errorOutput, "%v Logger.check error: failed to get caller\n", time.Now().UTC())
310
- log.errorOutput.Sync()
311
- }
312
-
313
- ce.Entry.Caller = zapcore.EntryCaller{
314
- Defined: defined,
315
- PC: frame.PC,
316
- File: frame.File,
317
- Line: frame.Line,
318
- Function: frame.Function,
319
- }
320
- }
321
- if log.addStack.Enabled(ce.Entry.Level) {
322
- ce.Entry.Stack = StackSkip("", log.callerSkip+callerSkipOffset).String
323
- }
324
-
325
- return ce
326
- }
327
-
328
- // getCallerFrame gets caller frame. The argument skip is the number of stack
329
- // frames to ascend, with 0 identifying the caller of getCallerFrame. The
330
- // boolean ok is false if it was not possible to recover the information.
331
- //
332
- // Note: This implementation is similar to runtime.Caller, but it returns the whole frame.
333
- func getCallerFrame(skip int) (frame runtime.Frame, ok bool) {
334
- const skipOffset = 2 // skip getCallerFrame and Callers
335
-
336
- pc := make([]uintptr, 1)
337
- numFrames := runtime.Callers(skip+skipOffset, pc[:])
338
- if numFrames < 1 {
339
- return
340
- }
341
-
342
- frame, _ = runtime.CallersFrames(pc).Next()
343
- return frame, frame.PC != 0
344
- }
@@ -1,140 +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
- }
@@ -1,161 +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
- "errors"
25
- "fmt"
26
- "io"
27
- "net/url"
28
- "os"
29
- "strings"
30
- "sync"
31
-
32
- "go.uber.org/zap/zapcore"
33
- )
34
-
35
- const schemeFile = "file"
36
-
37
- var (
38
- _sinkMutex sync.RWMutex
39
- _sinkFactories map[string]func(*url.URL) (Sink, error) // keyed by scheme
40
- )
41
-
42
- func init() {
43
- resetSinkRegistry()
44
- }
45
-
46
- func resetSinkRegistry() {
47
- _sinkMutex.Lock()
48
- defer _sinkMutex.Unlock()
49
-
50
- _sinkFactories = map[string]func(*url.URL) (Sink, error){
51
- schemeFile: newFileSink,
52
- }
53
- }
54
-
55
- // Sink defines the interface to write to and close logger destinations.
56
- type Sink interface {
57
- zapcore.WriteSyncer
58
- io.Closer
59
- }
60
-
61
- type nopCloserSink struct{ zapcore.WriteSyncer }
62
-
63
- func (nopCloserSink) Close() error { return nil }
64
-
65
- type errSinkNotFound struct {
66
- scheme string
67
- }
68
-
69
- func (e *errSinkNotFound) Error() string {
70
- return fmt.Sprintf("no sink found for scheme %q", e.scheme)
71
- }
72
-
73
- // RegisterSink registers a user-supplied factory for all sinks with a
74
- // particular scheme.
75
- //
76
- // All schemes must be ASCII, valid under section 3.1 of RFC 3986
77
- // (https://tools.ietf.org/html/rfc3986#section-3.1), and must not already
78
- // have a factory registered. Zap automatically registers a factory for the
79
- // "file" scheme.
80
- func RegisterSink(scheme string, factory func(*url.URL) (Sink, error)) error {
81
- _sinkMutex.Lock()
82
- defer _sinkMutex.Unlock()
83
-
84
- if scheme == "" {
85
- return errors.New("can't register a sink factory for empty string")
86
- }
87
- normalized, err := normalizeScheme(scheme)
88
- if err != nil {
89
- return fmt.Errorf("%q is not a valid scheme: %v", scheme, err)
90
- }
91
- if _, ok := _sinkFactories[normalized]; ok {
92
- return fmt.Errorf("sink factory already registered for scheme %q", normalized)
93
- }
94
- _sinkFactories[normalized] = factory
95
- return nil
96
- }
97
-
98
- func newSink(rawURL string) (Sink, error) {
99
- u, err := url.Parse(rawURL)
100
- if err != nil {
101
- return nil, fmt.Errorf("can't parse %q as a URL: %v", rawURL, err)
102
- }
103
- if u.Scheme == "" {
104
- u.Scheme = schemeFile
105
- }
106
-
107
- _sinkMutex.RLock()
108
- factory, ok := _sinkFactories[u.Scheme]
109
- _sinkMutex.RUnlock()
110
- if !ok {
111
- return nil, &errSinkNotFound{u.Scheme}
112
- }
113
- return factory(u)
114
- }
115
-
116
- func newFileSink(u *url.URL) (Sink, error) {
117
- if u.User != nil {
118
- return nil, fmt.Errorf("user and password not allowed with file URLs: got %v", u)
119
- }
120
- if u.Fragment != "" {
121
- return nil, fmt.Errorf("fragments not allowed with file URLs: got %v", u)
122
- }
123
- if u.RawQuery != "" {
124
- return nil, fmt.Errorf("query parameters not allowed with file URLs: got %v", u)
125
- }
126
- // Error messages are better if we check hostname and port separately.
127
- if u.Port() != "" {
128
- return nil, fmt.Errorf("ports not allowed with file URLs: got %v", u)
129
- }
130
- if hn := u.Hostname(); hn != "" && hn != "localhost" {
131
- return nil, fmt.Errorf("file URLs must leave host empty or use localhost: got %v", u)
132
- }
133
- switch u.Path {
134
- case "stdout":
135
- return nopCloserSink{os.Stdout}, nil
136
- case "stderr":
137
- return nopCloserSink{os.Stderr}, nil
138
- }
139
- return os.OpenFile(u.Path, os.O_WRONLY|os.O_APPEND|os.O_CREATE, 0666)
140
- }
141
-
142
- func normalizeScheme(s string) (string, error) {
143
- // https://tools.ietf.org/html/rfc3986#section-3.1
144
- s = strings.ToLower(s)
145
- if first := s[0]; 'a' > first || 'z' < first {
146
- return "", errors.New("must start with a letter")
147
- }
148
- for i := 1; i < len(s); i++ { // iterate over bytes, not runes
149
- c := s[i]
150
- switch {
151
- case 'a' <= c && c <= 'z':
152
- continue
153
- case '0' <= c && c <= '9':
154
- continue
155
- case c == '.' || c == '+' || c == '-':
156
- continue
157
- }
158
- return "", fmt.Errorf("may not contain %q", c)
159
- }
160
- return s, nil
161
- }