From 2174d5ed5e57cd4ff4c77e1c4d3b7b05efdb0c15 Mon Sep 17 00:00:00 2001
From: chenshijun <csj_sky@126.com>
Date: 星期五, 15 一月 2021 17:47:22 +0800
Subject: [PATCH] 维护日志的类型
---
logc.go | 30 +++++++++++++++---------------
1 files changed, 15 insertions(+), 15 deletions(-)
diff --git a/logc.go b/logc.go
index ed24bcc..8d35977 100644
--- a/logc.go
+++ b/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(),
--
Gitblit v1.8.0