field.go 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613
  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. package zap
  21. import (
  22. "fmt"
  23. "math"
  24. "time"
  25. "go.uber.org/zap/internal/stacktrace"
  26. "go.uber.org/zap/zapcore"
  27. )
  28. // Field is an alias for Field. Aliasing this type dramatically
  29. // improves the navigability of this package's API documentation.
  30. type Field = zapcore.Field
  31. var (
  32. _minTimeInt64 = time.Unix(0, math.MinInt64)
  33. _maxTimeInt64 = time.Unix(0, math.MaxInt64)
  34. )
  35. // Skip constructs a no-op field, which is often useful when handling invalid
  36. // inputs in other Field constructors.
  37. func Skip() Field {
  38. return Field{Type: zapcore.SkipType}
  39. }
  40. // nilField returns a field which will marshal explicitly as nil. See motivation
  41. // in https://github.com/uber-go/zap/issues/753 . If we ever make breaking
  42. // changes and add zapcore.NilType and zapcore.ObjectEncoder.AddNil, the
  43. // implementation here should be changed to reflect that.
  44. func nilField(key string) Field { return Reflect(key, nil) }
  45. // Binary constructs a field that carries an opaque binary blob.
  46. //
  47. // Binary data is serialized in an encoding-appropriate format. For example,
  48. // zap's JSON encoder base64-encodes binary blobs. To log UTF-8 encoded text,
  49. // use ByteString.
  50. func Binary(key string, val []byte) Field {
  51. return Field{Key: key, Type: zapcore.BinaryType, Interface: val}
  52. }
  53. // Bool constructs a field that carries a bool.
  54. func Bool(key string, val bool) Field {
  55. var ival int64
  56. if val {
  57. ival = 1
  58. }
  59. return Field{Key: key, Type: zapcore.BoolType, Integer: ival}
  60. }
  61. // Boolp constructs a field that carries a *bool. The returned Field will safely
  62. // and explicitly represent `nil` when appropriate.
  63. func Boolp(key string, val *bool) Field {
  64. if val == nil {
  65. return nilField(key)
  66. }
  67. return Bool(key, *val)
  68. }
  69. // ByteString constructs a field that carries UTF-8 encoded text as a []byte.
  70. // To log opaque binary blobs (which aren't necessarily valid UTF-8), use
  71. // Binary.
  72. func ByteString(key string, val []byte) Field {
  73. return Field{Key: key, Type: zapcore.ByteStringType, Interface: val}
  74. }
  75. // Complex128 constructs a field that carries a complex number. Unlike most
  76. // numeric fields, this costs an allocation (to convert the complex128 to
  77. // interface{}).
  78. func Complex128(key string, val complex128) Field {
  79. return Field{Key: key, Type: zapcore.Complex128Type, Interface: val}
  80. }
  81. // Complex128p constructs a field that carries a *complex128. The returned Field will safely
  82. // and explicitly represent `nil` when appropriate.
  83. func Complex128p(key string, val *complex128) Field {
  84. if val == nil {
  85. return nilField(key)
  86. }
  87. return Complex128(key, *val)
  88. }
  89. // Complex64 constructs a field that carries a complex number. Unlike most
  90. // numeric fields, this costs an allocation (to convert the complex64 to
  91. // interface{}).
  92. func Complex64(key string, val complex64) Field {
  93. return Field{Key: key, Type: zapcore.Complex64Type, Interface: val}
  94. }
  95. // Complex64p constructs a field that carries a *complex64. The returned Field will safely
  96. // and explicitly represent `nil` when appropriate.
  97. func Complex64p(key string, val *complex64) Field {
  98. if val == nil {
  99. return nilField(key)
  100. }
  101. return Complex64(key, *val)
  102. }
  103. // Float64 constructs a field that carries a float64. The way the
  104. // floating-point value is represented is encoder-dependent, so marshaling is
  105. // necessarily lazy.
  106. func Float64(key string, val float64) Field {
  107. return Field{Key: key, Type: zapcore.Float64Type, Integer: int64(math.Float64bits(val))}
  108. }
  109. // Float64p constructs a field that carries a *float64. The returned Field will safely
  110. // and explicitly represent `nil` when appropriate.
  111. func Float64p(key string, val *float64) Field {
  112. if val == nil {
  113. return nilField(key)
  114. }
  115. return Float64(key, *val)
  116. }
  117. // Float32 constructs a field that carries a float32. The way the
  118. // floating-point value is represented is encoder-dependent, so marshaling is
  119. // necessarily lazy.
  120. func Float32(key string, val float32) Field {
  121. return Field{Key: key, Type: zapcore.Float32Type, Integer: int64(math.Float32bits(val))}
  122. }
  123. // Float32p constructs a field that carries a *float32. The returned Field will safely
  124. // and explicitly represent `nil` when appropriate.
  125. func Float32p(key string, val *float32) Field {
  126. if val == nil {
  127. return nilField(key)
  128. }
  129. return Float32(key, *val)
  130. }
  131. // Int constructs a field with the given key and value.
  132. func Int(key string, val int) Field {
  133. return Int64(key, int64(val))
  134. }
  135. // Intp constructs a field that carries a *int. The returned Field will safely
  136. // and explicitly represent `nil` when appropriate.
  137. func Intp(key string, val *int) Field {
  138. if val == nil {
  139. return nilField(key)
  140. }
  141. return Int(key, *val)
  142. }
  143. // Int64 constructs a field with the given key and value.
  144. func Int64(key string, val int64) Field {
  145. return Field{Key: key, Type: zapcore.Int64Type, Integer: val}
  146. }
  147. // Int64p constructs a field that carries a *int64. The returned Field will safely
  148. // and explicitly represent `nil` when appropriate.
  149. func Int64p(key string, val *int64) Field {
  150. if val == nil {
  151. return nilField(key)
  152. }
  153. return Int64(key, *val)
  154. }
  155. // Int32 constructs a field with the given key and value.
  156. func Int32(key string, val int32) Field {
  157. return Field{Key: key, Type: zapcore.Int32Type, Integer: int64(val)}
  158. }
  159. // Int32p constructs a field that carries a *int32. The returned Field will safely
  160. // and explicitly represent `nil` when appropriate.
  161. func Int32p(key string, val *int32) Field {
  162. if val == nil {
  163. return nilField(key)
  164. }
  165. return Int32(key, *val)
  166. }
  167. // Int16 constructs a field with the given key and value.
  168. func Int16(key string, val int16) Field {
  169. return Field{Key: key, Type: zapcore.Int16Type, Integer: int64(val)}
  170. }
  171. // Int16p constructs a field that carries a *int16. The returned Field will safely
  172. // and explicitly represent `nil` when appropriate.
  173. func Int16p(key string, val *int16) Field {
  174. if val == nil {
  175. return nilField(key)
  176. }
  177. return Int16(key, *val)
  178. }
  179. // Int8 constructs a field with the given key and value.
  180. func Int8(key string, val int8) Field {
  181. return Field{Key: key, Type: zapcore.Int8Type, Integer: int64(val)}
  182. }
  183. // Int8p constructs a field that carries a *int8. The returned Field will safely
  184. // and explicitly represent `nil` when appropriate.
  185. func Int8p(key string, val *int8) Field {
  186. if val == nil {
  187. return nilField(key)
  188. }
  189. return Int8(key, *val)
  190. }
  191. // String constructs a field with the given key and value.
  192. func String(key string, val string) Field {
  193. return Field{Key: key, Type: zapcore.StringType, String: val}
  194. }
  195. // Stringp constructs a field that carries a *string. The returned Field will safely
  196. // and explicitly represent `nil` when appropriate.
  197. func Stringp(key string, val *string) Field {
  198. if val == nil {
  199. return nilField(key)
  200. }
  201. return String(key, *val)
  202. }
  203. // Uint constructs a field with the given key and value.
  204. func Uint(key string, val uint) Field {
  205. return Uint64(key, uint64(val))
  206. }
  207. // Uintp constructs a field that carries a *uint. The returned Field will safely
  208. // and explicitly represent `nil` when appropriate.
  209. func Uintp(key string, val *uint) Field {
  210. if val == nil {
  211. return nilField(key)
  212. }
  213. return Uint(key, *val)
  214. }
  215. // Uint64 constructs a field with the given key and value.
  216. func Uint64(key string, val uint64) Field {
  217. return Field{Key: key, Type: zapcore.Uint64Type, Integer: int64(val)}
  218. }
  219. // Uint64p constructs a field that carries a *uint64. The returned Field will safely
  220. // and explicitly represent `nil` when appropriate.
  221. func Uint64p(key string, val *uint64) Field {
  222. if val == nil {
  223. return nilField(key)
  224. }
  225. return Uint64(key, *val)
  226. }
  227. // Uint32 constructs a field with the given key and value.
  228. func Uint32(key string, val uint32) Field {
  229. return Field{Key: key, Type: zapcore.Uint32Type, Integer: int64(val)}
  230. }
  231. // Uint32p constructs a field that carries a *uint32. The returned Field will safely
  232. // and explicitly represent `nil` when appropriate.
  233. func Uint32p(key string, val *uint32) Field {
  234. if val == nil {
  235. return nilField(key)
  236. }
  237. return Uint32(key, *val)
  238. }
  239. // Uint16 constructs a field with the given key and value.
  240. func Uint16(key string, val uint16) Field {
  241. return Field{Key: key, Type: zapcore.Uint16Type, Integer: int64(val)}
  242. }
  243. // Uint16p constructs a field that carries a *uint16. The returned Field will safely
  244. // and explicitly represent `nil` when appropriate.
  245. func Uint16p(key string, val *uint16) Field {
  246. if val == nil {
  247. return nilField(key)
  248. }
  249. return Uint16(key, *val)
  250. }
  251. // Uint8 constructs a field with the given key and value.
  252. func Uint8(key string, val uint8) Field {
  253. return Field{Key: key, Type: zapcore.Uint8Type, Integer: int64(val)}
  254. }
  255. // Uint8p constructs a field that carries a *uint8. The returned Field will safely
  256. // and explicitly represent `nil` when appropriate.
  257. func Uint8p(key string, val *uint8) Field {
  258. if val == nil {
  259. return nilField(key)
  260. }
  261. return Uint8(key, *val)
  262. }
  263. // Uintptr constructs a field with the given key and value.
  264. func Uintptr(key string, val uintptr) Field {
  265. return Field{Key: key, Type: zapcore.UintptrType, Integer: int64(val)}
  266. }
  267. // Uintptrp constructs a field that carries a *uintptr. The returned Field will safely
  268. // and explicitly represent `nil` when appropriate.
  269. func Uintptrp(key string, val *uintptr) Field {
  270. if val == nil {
  271. return nilField(key)
  272. }
  273. return Uintptr(key, *val)
  274. }
  275. // Reflect constructs a field with the given key and an arbitrary object. It uses
  276. // an encoding-appropriate, reflection-based function to lazily serialize nearly
  277. // any object into the logging context, but it's relatively slow and
  278. // allocation-heavy. Outside tests, Any is always a better choice.
  279. //
  280. // If encoding fails (e.g., trying to serialize a map[int]string to JSON), Reflect
  281. // includes the error message in the final log output.
  282. func Reflect(key string, val interface{}) Field {
  283. return Field{Key: key, Type: zapcore.ReflectType, Interface: val}
  284. }
  285. // Namespace creates a named, isolated scope within the logger's context. All
  286. // subsequent fields will be added to the new namespace.
  287. //
  288. // This helps prevent key collisions when injecting loggers into sub-components
  289. // or third-party libraries.
  290. func Namespace(key string) Field {
  291. return Field{Key: key, Type: zapcore.NamespaceType}
  292. }
  293. // Stringer constructs a field with the given key and the output of the value's
  294. // String method. The Stringer's String method is called lazily.
  295. func Stringer(key string, val fmt.Stringer) Field {
  296. return Field{Key: key, Type: zapcore.StringerType, Interface: val}
  297. }
  298. // Time constructs a Field with the given key and value. The encoder
  299. // controls how the time is serialized.
  300. func Time(key string, val time.Time) Field {
  301. if val.Before(_minTimeInt64) || val.After(_maxTimeInt64) {
  302. return Field{Key: key, Type: zapcore.TimeFullType, Interface: val}
  303. }
  304. return Field{Key: key, Type: zapcore.TimeType, Integer: val.UnixNano(), Interface: val.Location()}
  305. }
  306. // Timep constructs a field that carries a *time.Time. The returned Field will safely
  307. // and explicitly represent `nil` when appropriate.
  308. func Timep(key string, val *time.Time) Field {
  309. if val == nil {
  310. return nilField(key)
  311. }
  312. return Time(key, *val)
  313. }
  314. // Stack constructs a field that stores a stacktrace of the current goroutine
  315. // under provided key. Keep in mind that taking a stacktrace is eager and
  316. // expensive (relatively speaking); this function both makes an allocation and
  317. // takes about two microseconds.
  318. func Stack(key string) Field {
  319. return StackSkip(key, 1) // skip Stack
  320. }
  321. // StackSkip constructs a field similarly to Stack, but also skips the given
  322. // number of frames from the top of the stacktrace.
  323. func StackSkip(key string, skip int) Field {
  324. // Returning the stacktrace as a string costs an allocation, but saves us
  325. // from expanding the zapcore.Field union struct to include a byte slice. Since
  326. // taking a stacktrace is already so expensive (~10us), the extra allocation
  327. // is okay.
  328. return String(key, stacktrace.Take(skip+1)) // skip StackSkip
  329. }
  330. // Duration constructs a field with the given key and value. The encoder
  331. // controls how the duration is serialized.
  332. func Duration(key string, val time.Duration) Field {
  333. return Field{Key: key, Type: zapcore.DurationType, Integer: int64(val)}
  334. }
  335. // Durationp constructs a field that carries a *time.Duration. The returned Field will safely
  336. // and explicitly represent `nil` when appropriate.
  337. func Durationp(key string, val *time.Duration) Field {
  338. if val == nil {
  339. return nilField(key)
  340. }
  341. return Duration(key, *val)
  342. }
  343. // Object constructs a field with the given key and ObjectMarshaler. It
  344. // provides a flexible, but still type-safe and efficient, way to add map- or
  345. // struct-like user-defined types to the logging context. The struct's
  346. // MarshalLogObject method is called lazily.
  347. func Object(key string, val zapcore.ObjectMarshaler) Field {
  348. return Field{Key: key, Type: zapcore.ObjectMarshalerType, Interface: val}
  349. }
  350. // Inline constructs a Field that is similar to Object, but it
  351. // will add the elements of the provided ObjectMarshaler to the
  352. // current namespace.
  353. func Inline(val zapcore.ObjectMarshaler) Field {
  354. return zapcore.Field{
  355. Type: zapcore.InlineMarshalerType,
  356. Interface: val,
  357. }
  358. }
  359. // Dict constructs a field containing the provided key-value pairs.
  360. // It acts similar to [Object], but with the fields specified as arguments.
  361. func Dict(key string, val ...Field) Field {
  362. return dictField(key, val)
  363. }
  364. // We need a function with the signature (string, T) for zap.Any.
  365. func dictField(key string, val []Field) Field {
  366. return Object(key, dictObject(val))
  367. }
  368. type dictObject []Field
  369. func (d dictObject) MarshalLogObject(enc zapcore.ObjectEncoder) error {
  370. for _, f := range d {
  371. f.AddTo(enc)
  372. }
  373. return nil
  374. }
  375. // We discovered an issue where zap.Any can cause a performance degradation
  376. // when used in new goroutines.
  377. //
  378. // This happens because the compiler assigns 4.8kb (one zap.Field per arm of
  379. // switch statement) of stack space for zap.Any when it takes the form:
  380. //
  381. // switch v := v.(type) {
  382. // case string:
  383. // return String(key, v)
  384. // case int:
  385. // return Int(key, v)
  386. // // ...
  387. // default:
  388. // return Reflect(key, v)
  389. // }
  390. //
  391. // To avoid this, we use the type switch to assign a value to a single local variable
  392. // and then call a function on it.
  393. // The local variable is just a function reference so it doesn't allocate
  394. // when converted to an interface{}.
  395. //
  396. // A fair bit of experimentation went into this.
  397. // See also:
  398. //
  399. // - https://github.com/uber-go/zap/pull/1301
  400. // - https://github.com/uber-go/zap/pull/1303
  401. // - https://github.com/uber-go/zap/pull/1304
  402. // - https://github.com/uber-go/zap/pull/1305
  403. // - https://github.com/uber-go/zap/pull/1308
  404. type anyFieldC[T any] func(string, T) Field
  405. func (f anyFieldC[T]) Any(key string, val any) Field {
  406. v, _ := val.(T)
  407. // val is guaranteed to be a T, except when it's nil.
  408. return f(key, v)
  409. }
  410. // Any takes a key and an arbitrary value and chooses the best way to represent
  411. // them as a field, falling back to a reflection-based approach only if
  412. // necessary.
  413. //
  414. // Since byte/uint8 and rune/int32 are aliases, Any can't differentiate between
  415. // them. To minimize surprises, []byte values are treated as binary blobs, byte
  416. // values are treated as uint8, and runes are always treated as integers.
  417. func Any(key string, value interface{}) Field {
  418. var c interface{ Any(string, any) Field }
  419. switch value.(type) {
  420. case zapcore.ObjectMarshaler:
  421. c = anyFieldC[zapcore.ObjectMarshaler](Object)
  422. case zapcore.ArrayMarshaler:
  423. c = anyFieldC[zapcore.ArrayMarshaler](Array)
  424. case []Field:
  425. c = anyFieldC[[]Field](dictField)
  426. case bool:
  427. c = anyFieldC[bool](Bool)
  428. case *bool:
  429. c = anyFieldC[*bool](Boolp)
  430. case []bool:
  431. c = anyFieldC[[]bool](Bools)
  432. case complex128:
  433. c = anyFieldC[complex128](Complex128)
  434. case *complex128:
  435. c = anyFieldC[*complex128](Complex128p)
  436. case []complex128:
  437. c = anyFieldC[[]complex128](Complex128s)
  438. case complex64:
  439. c = anyFieldC[complex64](Complex64)
  440. case *complex64:
  441. c = anyFieldC[*complex64](Complex64p)
  442. case []complex64:
  443. c = anyFieldC[[]complex64](Complex64s)
  444. case float64:
  445. c = anyFieldC[float64](Float64)
  446. case *float64:
  447. c = anyFieldC[*float64](Float64p)
  448. case []float64:
  449. c = anyFieldC[[]float64](Float64s)
  450. case float32:
  451. c = anyFieldC[float32](Float32)
  452. case *float32:
  453. c = anyFieldC[*float32](Float32p)
  454. case []float32:
  455. c = anyFieldC[[]float32](Float32s)
  456. case int:
  457. c = anyFieldC[int](Int)
  458. case *int:
  459. c = anyFieldC[*int](Intp)
  460. case []int:
  461. c = anyFieldC[[]int](Ints)
  462. case int64:
  463. c = anyFieldC[int64](Int64)
  464. case *int64:
  465. c = anyFieldC[*int64](Int64p)
  466. case []int64:
  467. c = anyFieldC[[]int64](Int64s)
  468. case int32:
  469. c = anyFieldC[int32](Int32)
  470. case *int32:
  471. c = anyFieldC[*int32](Int32p)
  472. case []int32:
  473. c = anyFieldC[[]int32](Int32s)
  474. case int16:
  475. c = anyFieldC[int16](Int16)
  476. case *int16:
  477. c = anyFieldC[*int16](Int16p)
  478. case []int16:
  479. c = anyFieldC[[]int16](Int16s)
  480. case int8:
  481. c = anyFieldC[int8](Int8)
  482. case *int8:
  483. c = anyFieldC[*int8](Int8p)
  484. case []int8:
  485. c = anyFieldC[[]int8](Int8s)
  486. case string:
  487. c = anyFieldC[string](String)
  488. case *string:
  489. c = anyFieldC[*string](Stringp)
  490. case []string:
  491. c = anyFieldC[[]string](Strings)
  492. case uint:
  493. c = anyFieldC[uint](Uint)
  494. case *uint:
  495. c = anyFieldC[*uint](Uintp)
  496. case []uint:
  497. c = anyFieldC[[]uint](Uints)
  498. case uint64:
  499. c = anyFieldC[uint64](Uint64)
  500. case *uint64:
  501. c = anyFieldC[*uint64](Uint64p)
  502. case []uint64:
  503. c = anyFieldC[[]uint64](Uint64s)
  504. case uint32:
  505. c = anyFieldC[uint32](Uint32)
  506. case *uint32:
  507. c = anyFieldC[*uint32](Uint32p)
  508. case []uint32:
  509. c = anyFieldC[[]uint32](Uint32s)
  510. case uint16:
  511. c = anyFieldC[uint16](Uint16)
  512. case *uint16:
  513. c = anyFieldC[*uint16](Uint16p)
  514. case []uint16:
  515. c = anyFieldC[[]uint16](Uint16s)
  516. case uint8:
  517. c = anyFieldC[uint8](Uint8)
  518. case *uint8:
  519. c = anyFieldC[*uint8](Uint8p)
  520. case []byte:
  521. c = anyFieldC[[]byte](Binary)
  522. case uintptr:
  523. c = anyFieldC[uintptr](Uintptr)
  524. case *uintptr:
  525. c = anyFieldC[*uintptr](Uintptrp)
  526. case []uintptr:
  527. c = anyFieldC[[]uintptr](Uintptrs)
  528. case time.Time:
  529. c = anyFieldC[time.Time](Time)
  530. case *time.Time:
  531. c = anyFieldC[*time.Time](Timep)
  532. case []time.Time:
  533. c = anyFieldC[[]time.Time](Times)
  534. case time.Duration:
  535. c = anyFieldC[time.Duration](Duration)
  536. case *time.Duration:
  537. c = anyFieldC[*time.Duration](Durationp)
  538. case []time.Duration:
  539. c = anyFieldC[[]time.Duration](Durations)
  540. case error:
  541. c = anyFieldC[error](NamedError)
  542. case []error:
  543. c = anyFieldC[[]error](Errors)
  544. case fmt.Stringer:
  545. c = anyFieldC[fmt.Stringer](Stringer)
  546. default:
  547. c = anyFieldC[any](Reflect)
  548. }
  549. return c.Any(key, value)
  550. }