const.go 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. package zapx
  2. import "time"
  3. // 消息队列名称
  4. const (
  5. QueueOperateRecord = "clickhouse_operation" // 操作记录队列
  6. QueueLogRecord = "clickhouse_log" // 日志记录队列
  7. )
  8. // StringEntry 字符串键值对
  9. type StringEntry struct {
  10. Key string `json:"key"` // 键
  11. Value string `json:"value"` // 值
  12. }
  13. // FloatEntry 浮点数键值对
  14. type FloatEntry struct {
  15. Key string `json:"key"` // 键
  16. Value float64 `json:"value"` // 值
  17. }
  18. // IntEntry 整数键值对
  19. type IntEntry struct {
  20. Key string `json:"key"` // 键
  21. Value int32 `json:"value"` // 值
  22. }
  23. // BoolEntry 布尔键值对
  24. type BoolEntry struct {
  25. Key string `json:"key"` // 键
  26. Value bool `json:"value"` // 值
  27. }
  28. // LogRecord 定义结构化日志记录的数据结构。
  29. // 因为结构化日志允许重复的键值对,所以使用切片类型模拟字典。
  30. // 不支持嵌套类型。嵌套类型可使用 json path 做 key。如 "a.b[1].c"。
  31. type LogRecord struct {
  32. EventTime time.Time `json:"eventTime"` // 日志时间。必填。
  33. Category string `json:"category"` // 工程分类。必填。
  34. Level string `json:"level"` // 日志等级
  35. Caller string `json:"caller"` // 日志调用位置
  36. Message string `json:"message"` // 日志消息
  37. StringEntries []StringEntry `json:"stringEntries"` // 字符串键值对
  38. FloatEntries []FloatEntry `json:"floatEntries"` // 浮点数键值对
  39. IntEntries []IntEntry `json:"intEntries"` // 整数键值对
  40. BoolEntries []BoolEntry `json:"boolEntries"` // 布尔键值对
  41. }