glogcenter/glc/ldb/storage/logdata_model.go

38 lines
1.6 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* 日志模型
* 1面向日志接口设定常用属性方便扩充
*/
package storage
import (
"encoding/json"
"glc/cmn"
)
// Text是必须有的日志内容Id自增内置其他属性可选
// 其中Tags是空格分隔的标签日期外各属性值会按空格分词
// 对应的json属性统一全小写
type LogDataModel struct {
Id uint64 `json:"id,omitempty"` // 从1开始递增
Text string `json:"text,omitempty"` // 【必须】日志内容,多行时仅为首行,直接显示用,是全文检索对象
Detail string `json:"detail,omitempty"` // 多行时的详细日志信息,通常是包含错误堆栈等的日志内容
Date string `json:"date,omitempty"` // 多行时的详细日志信息,通常是包含错误堆栈等的日志内容
Tags []string `json:"tags,omitempty"` // 自定义标签,都作为关键词看待处理
Server string `json:"server,omitempty"` // 服务器
Client string `json:"client,omitempty"` // 客户端
User string `json:"user,omitempty"` // 用户
System string `json:"system,omitempty"` // 所属系统
TraceId string `json:"traceid,omitempty"` // 跟踪ID
Keywords []string `json:"keywords,omitempty"` // 自定义的关键词
Sensitives []string `json:"sensitives,omitempty"` // 要删除的敏感词
}
func (d *LogDataModel) ToJson() string {
bt, _ := json.Marshal(d)
return cmn.BytesToString(bt)
}
func (d *LogDataModel) LoadJson(jsonstr string) {
json.Unmarshal(cmn.StringToBytes(jsonstr), d)
}