package logs import ( "fmt" "github.com/astaxie/beego/logs" orm2 "github.com/beego/beego/v2/client/orm" "runtime" ) var Test = true var logx *logs.BeeLogger var logxE *logs.BeeLogger var logxMqtt *logs.BeeLogger var logxData *logs.BeeLogger var logxOrm *logs.BeeLogger func init() { if runtime.GOOS == "windows" { Test = true } else { Test = false } logx = logs.NewLogger() logx.SetLogger(logs.AdapterFile, `{"filename":"logs/logx/logx.log"}`) logxE = logs.NewLogger() logxE.SetLogger(logs.AdapterFile, `{"filename":"logs/logxE/logx.log"}`) logxMqtt = logs.NewLogger() logxMqtt.SetLogger(logs.AdapterFile, `{"filename":"logs/Mqtt/logx.log"}`) logxData = logs.NewLogger() logxData.SetLogger(logs.AdapterFile, `{"filename":"logs/Data/logx.log"}`) logxOrm = logs.NewLogger() logxOrm.SetLogger(logs.AdapterFile, `{"filename":"logs/Orm/logx.log"}`) if !Test { orm2.DebugLog = orm2.NewLog(logxOrm) } // // 测试 日志分割 //go func() { // t := 1 // orm2.DebugLog.Println("==========DebugLog=========") // for true { // t +=1 // orm2.DebugLog.Println("DebugLog:",t) // time.Sleep(time.Second * 1) // } //}() //go TimeTask.OrmLog_MonitorScanStatus() } func Println(format string, v ...interface{}) { if Test { fmt.Println(format, v) } logx.Info(format, v) } func PrintlnError(format string, v ...interface{}) { if Test { fmt.Println(format, v) } logxE.Error(format, v) logx.Info(format, v) } func PrintlnMqtt(str string) { if Test { fmt.Println(str) } logxMqtt.Info(str) } func PrintlnData(str string) { if Test { fmt.Println(str) } logxData.Info(str) } //func Println(a ...interface{}) { // if test { // fmt.Printf("=>", a) // } // logx.Info(">", a) //} // 日志 // logs.Println(time.Now().Format("2006-01-02 15:04:05"), "=>", a) // 重要 // logs.Println("MqttServer", " 存在报警 跳过:", string(msg)) // 严重 // logs.Println("MqttServer", " 存在报警 跳过:", string(msg))