logger.go 278 B

12345678910111213141516
  1. package logger
  2. import (
  3. "log"
  4. "os"
  5. )
  6. func init() {
  7. file, err := os.OpenFile("./log.txt", os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0666)
  8. if err != nil {
  9. panic(any("open log file error"))
  10. }
  11. log.SetFlags(log.Ldate)
  12. log.SetPrefix("earlyWarningSystem")
  13. log.SetOutput(file)
  14. }