代码拉取完成,页面将自动刷新
package internal
// Fields type defines the dynamic field collection of the log.
// After Fields are created, their stored keys will not change.
type Fields map[string]interface{}
// Clone returns a cloned Fields.
// If n is given, the returned fields will be pre-expanded with equal capacity.
func (fs Fields) Clone(n int) Fields {
if len(fs) == 0 {
return make(Fields, n)
}
r := make(Fields, len(fs)+n)
for k, v := range fs {
r[k] = v
}
return r
}
// With returns a cloned Fields and adds the given data to it.
func (fs Fields) With(src map[string]interface{}) Fields {
if len(src) == 0 {
return fs.Clone(0)
}
r := fs.Clone(len(src))
for k, v := range src {
r[k] = v
}
return r
}
// StandardiseFieldsForJSONEncoder standardizes the given log fields.
func StandardiseFieldsForJSONEncoder(src map[string]interface{}) map[string]interface{} {
dst := make(map[string]interface{}, len(src))
for k, v := range src {
switch o := v.(type) {
case error:
// The json.Marshal will convert some errors into "{}", we need to call
// the error.Error() method before JSON encoding.
dst[k] = o.Error()
default:
dst[k] = v
}
}
return dst
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。