2 Star 0 Fork 0

djienet/kratos

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
field.go 1.70 KB
一键复制 编辑 原始数据 按行查看 历史
chenli 提交于 2020-11-02 15:38 +08:00 . update
package log
import (
"math"
"time"
"gitee.com/djienet/kratos/pkg/log/internal/core"
)
// D represents a map of entry level data used for structured logging.
// type D map[string]interface{}
type D = core.Field
// KVString construct Field with string value.
func KVString(key string, value string) D {
return D{Key: key, Type: core.StringType, StringVal: value}
}
// KVInt construct Field with int value.
func KVInt(key string, value int) D {
return D{Key: key, Type: core.IntTpye, Int64Val: int64(value)}
}
// KVInt64 construct D with int64 value.
func KVInt64(key string, value int64) D {
return D{Key: key, Type: core.Int64Type, Int64Val: value}
}
// KVUint construct Field with uint value.
func KVUint(key string, value uint) D {
return D{Key: key, Type: core.UintType, Int64Val: int64(value)}
}
// KVUint64 construct Field with uint64 value.
func KVUint64(key string, value uint64) D {
return D{Key: key, Type: core.Uint64Type, Int64Val: int64(value)}
}
// KVFloat32 construct Field with float32 value.
func KVFloat32(key string, value float32) D {
return D{Key: key, Type: core.Float32Type, Int64Val: int64(math.Float32bits(value))}
}
// KVFloat64 construct Field with float64 value.
func KVFloat64(key string, value float64) D {
return D{Key: key, Type: core.Float64Type, Int64Val: int64(math.Float64bits(value))}
}
// KVDuration construct Field with Duration value.
func KVDuration(key string, value time.Duration) D {
return D{Key: key, Type: core.DurationType, Int64Val: int64(value)}
}
// KV return a log kv for logging field.
// NOTE: use KV{type name} can avoid object alloc and get better performance. []~( ̄▽ ̄)~*干杯
func KV(key string, value interface{}) D {
return D{Key: key, Value: value}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/djienet/kratos.git
git@gitee.com:djienet/kratos.git
djienet
kratos
kratos
v1.1.7

搜索帮助