LogPrintln.go 592 B

123456789101112131415161718192021222324252627282930313233343536
  1. package logs
  2. import (
  3. "fmt"
  4. "github.com/astaxie/beego/logs"
  5. "runtime"
  6. "time"
  7. )
  8. var logx *logs.BeeLogger
  9. var Test = true
  10. func init() {
  11. logx = logs.NewLogger()
  12. logx.SetLogger(logs.AdapterFile, `{"filename":"logs/logx/logx.log"}`)
  13. if runtime.GOOS == "windows" {
  14. Test = true
  15. } else {
  16. Test = false
  17. }
  18. }
  19. func Println(a ...interface{}) {
  20. if Test {
  21. fmt.Println(time.Now().Format("2006-01-02 15:04:05"), "=>", a)
  22. }
  23. logx.Info(time.Now().Format("2006-01-02 15:04:05")+">", a)
  24. }
  25. //func Println(a ...interface{}) {
  26. // if test {
  27. // fmt.Printf("=>", a)
  28. // }
  29. // logx.Info(">", a)
  30. //}