Ai
1 Star 0 Fork 0

黄海苗/otel_zap_logger

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
field.go 1.77 KB
一键复制 编辑 原始数据 按行查看 历史
黄海苗 提交于 2023-06-15 14:34 +08:00 . 从github迁过来
package otel_zap_logger
import (
"fmt"
)
type FieldType int
const (
UnknownType FieldType = iota
BoolType
BoolSliceType
IntType
IntSliceType
Int64Type
Int64SliceType
Float64Type
Float64SliceType
StringType
StringSliceType
StringerType
)
type Field struct {
Key string
Type FieldType
Bool bool
Bools []bool
Integer int
Integers []int
String string
Float64 float64
Integer64 int64
Integer64s []int64
Strings []string
Float64s []float64
}
// Bool
func Bool(key string, val bool) Field {
return Field{Key: key, Type: BoolType, Bool: val}
}
// BoolSlice
func BoolSlice(key string, val []bool) Field {
return Field{Key: key, Type: BoolSliceType, Bools: val}
}
// Int
func Int(key string, val int) Field {
return Field{Key: key, Type: IntType, Integer: val}
}
// IntSlice
func IntSlice(key string, val []int) Field {
return Field{Key: key, Type: IntSliceType, Integers: val}
}
// Int64
func Int64(key string, val int64) Field {
return Field{Key: key, Type: Int64Type, Integer64: val}
}
// Int64Slice
func Int64Slice(key string, val []int64) Field {
return Field{Key: key, Type: Int64SliceType, Integer64s: val}
}
// Float64
func Float64(key string, val float64) Field {
return Field{Key: key, Type: Float64Type, Float64: val}
}
// Float64Slice
func Float64Slice(key string, val []float64) Field {
return Field{Key: key, Type: Float64SliceType, Float64s: val}
}
// String
func String(key string, val string) Field {
return Field{Key: key, Type: StringType, String: val}
}
// StringSlice
func StringSlice(key string, val []string) Field {
return Field{Key: key, Type: StringSliceType, Strings: val}
}
// Stringer
func Stringer(key string, val fmt.Stringer) Field {
return Field{Key: key, Type: StringerType, String: val.String()}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/Himan000/otel_zap_logger.git
git@gitee.com:Himan000/otel_zap_logger.git
Himan000
otel_zap_logger
otel_zap_logger
aab65004a158

搜索帮助