097e38ece3fd301363eb5e67e8f7be840fc46e94..2174d5ed5e57cd4ff4c77e1c4d3b7b05efdb0c15
2021-01-15 chenshijun
维护日志的类型
2174d5 对比 | 目录
2021-01-13 chenshijun
修改日志格式化的代码
d5f4c1 对比 | 目录
2021-01-13 chenshijun
增加日志类型
eb448e 对比 | 目录
1个文件已修改
30 ■■■■ 已修改文件
logc.go 30 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
logc.go
@@ -18,12 +18,13 @@
)
const (
    TypeManual = iota + 1
    TypeLoginOut
    TypePollInfo
    TypeStackInfo
    TypeWarnInfo
    TypeRunInfo
    TypeManual = iota + 1  //人工操作日志,系统升级,摄像机修改,算法修改...
    TypeLoginOut //登录登出日志
    TypePollInfo //轮巡摄像机及其对应的算法
    TypeStackInfo //数据栈处理情况
    TypeWarnInfo //故障信息
    TypeRunInfo //运行情况,gpu,mem,cpu
    TypeSysInfo //系统参数变更,ip,server name,开关机信息
)
type LogInfo struct {
@@ -54,22 +55,21 @@
    go saveLoop()
}
func Save(level int, logType int,template string, v ...interface{}) {
    cache(level, logType, "", "", template, v)
func Save(level int, logType int, v ...interface{}) {
    cache(level, logType, "", "", v)
}
func SaveManual(level int, logType int, userID string, userName string, template string, v ...interface{}) {
    cache(level, logType, userID, userName, template, v)
func SaveManual(level int, logType int, userID string, userName string, v ...interface{}) {
    cache(level, logType, userID, userName, v)
}
func cache(level int, logType int, userID string, userName string, template string, fmtArgs []interface{}) {
func cache(level int, logType int, userID string, userName string, fmtArgs []interface{}) {
    // Format with Sprint, Sprintf, or neither.
    msg := template
    if msg == "" && len(fmtArgs) > 0 {
    msg := ""
    if len(fmtArgs) > 0 {
        msg = fmt.Sprint(fmtArgs...)
    } else if msg != "" && len(fmtArgs) > 0 {
        msg = fmt.Sprintf(template, fmtArgs...)
    }
    fmt.Println(msg)
    log := LogInfo {
        ID:        uuid.NewV4().String(),