feat: Implement core backend services for team owner management, SQLite persistence, and logging, alongside frontend monitoring and record views.
This commit is contained in:
@@ -2,6 +2,8 @@ package logger
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
)
|
||||
@@ -84,6 +86,35 @@ func log(level, message, email, module string) {
|
||||
colorYellow := "\033[33m"
|
||||
colorCyan := "\033[36m"
|
||||
|
||||
// Team 颜色列表(用于区分不同 Team)
|
||||
teamColors := []string{
|
||||
"\033[38;5;39m", // 亮蓝
|
||||
"\033[38;5;208m", // 橙色
|
||||
"\033[38;5;141m", // 紫色
|
||||
"\033[38;5;48m", // 青绿
|
||||
"\033[38;5;197m", // 粉红
|
||||
"\033[38;5;226m", // 亮黄
|
||||
"\033[38;5;87m", // 青色
|
||||
"\033[38;5;156m", // 浅绿
|
||||
"\033[38;5;219m", // 浅粉
|
||||
"\033[38;5;117m", // 天蓝
|
||||
}
|
||||
|
||||
// 从消息中提取 Team 编号
|
||||
teamColor := ""
|
||||
if strings.Contains(message, "[Team ") {
|
||||
start := strings.Index(message, "[Team ")
|
||||
if start >= 0 {
|
||||
end := strings.Index(message[start:], "]")
|
||||
if end > 0 {
|
||||
teamStr := message[start+6 : start+end]
|
||||
if teamNum, err := strconv.Atoi(teamStr); err == nil && teamNum > 0 {
|
||||
teamColor = teamColors[(teamNum-1)%len(teamColors)]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
prefix := ""
|
||||
color := ""
|
||||
switch level {
|
||||
@@ -101,16 +132,22 @@ func log(level, message, email, module string) {
|
||||
color = colorYellow
|
||||
}
|
||||
|
||||
// 如果是 Team 相关日志,消息使用 Team 颜色
|
||||
msgColor := colorReset
|
||||
if teamColor != "" {
|
||||
msgColor = teamColor
|
||||
}
|
||||
|
||||
if email != "" {
|
||||
fmt.Printf("%s%s%s %s[%s]%s [%s] %s - %s\n",
|
||||
fmt.Printf("%s%s%s %s[%s]%s [%s] %s - %s%s%s\n",
|
||||
colorGray, timestamp, colorReset,
|
||||
color, prefix, colorReset,
|
||||
module, email, message)
|
||||
module, email, msgColor, message, colorReset)
|
||||
} else {
|
||||
fmt.Printf("%s%s%s %s[%s]%s [%s] %s\n",
|
||||
fmt.Printf("%s%s%s %s[%s]%s [%s] %s%s%s\n",
|
||||
colorGray, timestamp, colorReset,
|
||||
color, prefix, colorReset,
|
||||
module, message)
|
||||
module, msgColor, message, colorReset)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user