package proposal import ( "encoding/json" ) // RequestLoggerMessage 日志消息 type RequestLoggerMessage struct { Tid string `json:"tid"` // 请求链路 ID Username string `json:"username"` // 用户名 HOST string `json:"host"` // 请求 HOST Path string `json:"path"` // 请求 Path Method string `json:"method"` // 请求 Method HTTPCode int `json:"http_code"` // HTTP 状态码 BusinessCode int `json:"business_code"` // 业务码 CostSeconds float64 `json:"cost_seconds"` // 耗时,单位:秒 IsSuccess bool `json:"is_success"` // 状态,是否成功 Content string `json:"content"` // 内容 } // Marshal 序列化到JSON func (m *RequestLoggerMessage) Marshal() (jsonRaw []byte) { jsonRaw, _ = json.Marshal(m) return } // RequestLoggerHandler 日志记录句柄 type RequestLoggerHandler func(msg *RequestLoggerMessage)