Documentation
¶
Index ¶
- Constants
- Variables
- func Bool[T any](value T) bool
- func Compare(a, b any, isDesc bool) int
- func Contains(array []string, target string) bool
- func GetLogger() *slog.Logger
- func GetType(val any) string
- func GetVal(value []byte, dataType parser.ValueType) any
- func GetValue(key string) (any, bool)
- func If[T, U any](isTrue T, ifValue U, elseValue U) U
- func IsInvalidUUKey(key string) bool
- func Log(logid string, args ...interface{})
- func LogDebug(logid string, args ...interface{})
- func LogDebugKV(logid string, msg string, attrs ...any)
- func LogDebugf(logid string, format string, args ...interface{})
- func LogError(logid string, args ...interface{})
- func LogErrorKV(logid string, msg string, attrs ...any)
- func LogErrorf(logid string, format string, args ...interface{})
- func LogInfo(logid string, args ...interface{})
- func LogInfoKV(logid string, msg string, attrs ...any)
- func LogInfof(logid string, format string, args ...interface{})
- func LogKVByCostMs(logid, msg string, costMs int64, attrs ...any)
- func LogWarn(logid string, args ...interface{})
- func LogWarnKV(logid string, msg string, attrs ...any)
- func LogWarnf(logid string, format string, args ...interface{})
- func LogWatchCostMs(start time.Time, logid, msg string, extra ...any)
- func Logf(logid string, format string, args ...interface{})
- func Or[T any](ifValue T, elseValue T) T
- func ParseDate(val any) *time.Time
- func ParseNumber(val any) float64
- func Register(key string, val any)
- func RemoveValue(name string)
- func SetLogLevel(level string)
- func SlowLogThreshold() int64
- func ToJson(val any) string
- type SNConfig
- type SNOption
- type SerialNo
Constants ¶
View Source
const ( GROWTH = "GROWTH" FILTER = "FILTER" )
View Source
const ( KIND_CONSTANT = "CONSTANT" KIND_DATETIME = "DATETIME" KIND_COUNTING = "COUNTING" )
View Source
const DefaultSlowLogThresholdMs int64 = 50
DefaultSlowLogThresholdMs 未 Register(consts.SLOW_THRESHOLD) 时的回退值(毫秒)。
Variables ¶
View Source
var ALL_KINDS = []string{ KIND_CONSTANT, KIND_DATETIME, KIND_COUNTING, }
View Source
var AggrByEmptyParams = fmt.Errorf("Upsert Error: %s", "AggrByEmptyParams")
View Source
var ConfigNotExsit = fmt.Errorf("Load Error: %s", "ConfigNotExsit")
View Source
var EntryNotExsit = fmt.Errorf("Load Error: %s", "EntryNotExsit")
View Source
var ErrorConfigClient = fmt.Errorf("Load Error: %s", "ErrorConfigClient")
View Source
var ErrorConfigFields = fmt.Errorf("Load Error: %s", "ErrorConfigFields")
View Source
var ErrorConfigTables = fmt.Errorf("Load Error: %s", "ErrorConfigTables")
View Source
var ErrorInputField = fmt.Errorf("Load Error: %s", "ErrorInputField")
View Source
var ErrorModelDriver = fmt.Errorf("Load Error: %s", "ErrorModelDriver")
View Source
var ErrorModelSource = fmt.Errorf("Load Error: %s", "ErrorModelSource")
View Source
var ErrorTableField = fmt.Errorf("Load Error: %s", "ErrorTableField")
View Source
var Errorf = fmt.Errorf
View Source
var IsError = errors.Is
View Source
var Printf = fmt.Printf
View Source
var Println = fmt.Println
View Source
var RecordsFoundWhenFirst = fmt.Errorf("Upsert Error: %s", "RecordsFoundWhenFirst")
View Source
var Replace = strings.Replace
View Source
var Split = strings.Split
View Source
var Sprint = fmt.Sprint
View Source
var Sprintf = fmt.Sprintf
View Source
var ToLower = strings.ToLower
View Source
var ToUpper = strings.ToUpper
View Source
var UnexpectedFormat = fmt.Errorf("Data Error: %s", "UnexpectFormat")
View Source
var UpsertEmptyRecord = fmt.Errorf("Upsert Error: %s", "UpsertEmptyRecord")
Functions ¶
func IsInvalidUUKey ¶
func LogKVByCostMs ¶
LogKVByCostMs 按 SlowLogThreshold 选择 INFO/DEBUG,并写入 cost_ms(置于 attrs 前部)。
func LogWatchCostMs ¶
LogWatchCostMs 用于 defer:根据注册 defer 时传入的 start,记录到当前返回为止的耗时。 cost_ms > SlowLogThreshold 时写 INFO,否则 DEBUG。 logid 可为空;msg 为日志语义标题;extra 为成对键值,语义与 LogInfoKV 的 attrs 一致。 会自动在首部附加 cost_ms(毫秒整数)。
用法:defer LogWatchCostMs(time.Now(), logid, "my op", "key1", v1, "key2", v2)
func ParseNumber ¶
func RemoveValue ¶
func RemoveValue(name string)
func SlowLogThreshold ¶
func SlowLogThreshold() int64
SlowLogThreshold 返回慢日志阈值:读 GetValue(consts.SLOW_THRESHOLD),期望为整型(如 int64)。
Types ¶
Click to show internal directories.
Click to hide internal directories.