This commit is contained in:
azw 2023-08-13 12:08:30 +08:00
parent f18d01d8a5
commit 01f43ab4a0
2 changed files with 15 additions and 12 deletions

View File

@ -13,7 +13,7 @@ func GetSysLog() *SysLog_ {
return _sysLog
}
func GteTgLog() *TGLog_ {
func GetTgLog() *TGLog_ {
return _tgLog
}

View File

@ -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 {