From 01f43ab4a04199e2663d0cbb99f564e8fe4cdef2 Mon Sep 17 00:00:00 2001 From: azw Date: Sun, 13 Aug 2023 12:08:30 +0800 Subject: [PATCH] 1 --- export.go | 2 +- syslog.go | 25 ++++++++++++++----------- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/export.go b/export.go index eb4ff0c..2b8335a 100644 --- a/export.go +++ b/export.go @@ -13,7 +13,7 @@ func GetSysLog() *SysLog_ { return _sysLog } -func GteTgLog() *TGLog_ { +func GetTgLog() *TGLog_ { return _tgLog } diff --git a/syslog.go b/syslog.go index 0273933..eb7fd73 100644 --- a/syslog.go +++ b/syslog.go @@ -22,6 +22,7 @@ const SYS_LOG_ROOT = "/data/logs/%s/logs/" const SYS_LOG_FILENAME = "log_%d_%s.log" type LogMsgNode struct { + category int32 logMsg string next *LogMsgNode } @@ -47,59 +48,61 @@ func (this *SysLog_) Emergency(format string, args ...interface{}) { if this.logLevel > LOG_EMERGENCY { return } - this.addLog("[EMERGENCY]", format, args...) + this.addLog(LOG_EMERGENCY, "[EMERGENCY]", format, args...) } func (this *SysLog_) Alert(format string, args ...interface{}) { if this.logLevel > LOG_ALERT { return } - this.addLog("[ALERT]", format, args...) + this.addLog(LOG_ALERT, "[ALERT]", format, args...) } func (this *SysLog_) Error(format string, args ...interface{}) { if this.logLevel > LOG_ERROR { return } - this.addLog("[ERROR]", format, args...) + this.addLog(LOG_ERROR, "[ERROR]", format, args...) } func (this *SysLog_) Warning(format string, args ...interface{}) { if this.logLevel > LOG_WARNING { return } - this.addLog("[WARNING]", format, args...) + this.addLog(LOG_WARNING, "[WARNING]", format, args...) } func (this *SysLog_) Notice(format string, args ...interface{}) { if this.logLevel > LOG_NOTICE { return } - this.addLog("[NOTICE]", format, args...) + this.addLog(LOG_NOTICE, "[NOTICE]", format, args...) } func (this *SysLog_) Info(format string, args ...interface{}) { if this.logLevel > LOG_INFO { return } - this.addLog("[INFO]", format, args...) + this.addLog(LOG_INFO, "[INFO]", format, args...) } func (this *SysLog_) Debug(format string, args ...interface{}) { if this.logLevel > LOG_DEBUG { return } - this.addLog("[DEBUG]", format, args...) + this.addLog(LOG_DEBUG, "[DEBUG]", format, args...) } -func (this *SysLog_) addLog(category string, format string, args ...interface{}) { +func (this *SysLog_) addLog(category int32, prefixStr string, + format string, args ...interface{}) { p := &LogMsgNode{} + p.category = category p.logMsg = time.Now().Format("2006-01-02 15:04:05") + - category + " " + + prefixStr + " " + fmt.Sprintf(format, args...) + "\n" - /*if q5.Debug() { + if category == LOG_INFO { fmt.Print(p.logMsg) - }*/ + } this.msgMutex.Lock() defer this.msgMutex.Unlock() if this.botNode != nil {