OrmLog.go 547 B

123456789101112131415161718192021222324252627
  1. package TimeTask
  2. import (
  3. "PublishCode/logs"
  4. "fmt"
  5. "io/ioutil"
  6. "os"
  7. "time"
  8. )
  9. var OrmLogOrmLog *os.File
  10. func OrmLog_MonitorScanStatus() {
  11. logs.Println("------- ORM 日志清理 --------")
  12. Data, err := ioutil.ReadFile(OrmLogOrmLog.Name())
  13. if err != nil {
  14. fmt.Printf("文件打开失败=%v\n", err)
  15. return
  16. }
  17. err = ioutil.WriteFile("logs/orm/logx_"+time.Now().Format("2006-01-02")+".log", Data, 0666)
  18. if err != nil {
  19. fmt.Printf("文件打开失败=%v\n", err)
  20. }
  21. logs.Println("清空:", os.Truncate(OrmLogOrmLog.Name(), 0))
  22. }