LogPrintln.go 677 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package logs
  2. import (
  3. "fmt"
  4. "github.com/astaxie/beego/logs"
  5. "runtime"
  6. )
  7. var Test = true
  8. var logx *logs.BeeLogger
  9. var logxE *logs.BeeLogger
  10. func init() {
  11. if runtime.GOOS == "windows" {
  12. Test = true
  13. } else {
  14. Test = false
  15. }
  16. logx = logs.NewLogger()
  17. logx.SetLogger(logs.AdapterFile, `{"filename":"logs/logx/logx.log"}`)
  18. logxE = logs.NewLogger()
  19. logxE.SetLogger(logs.AdapterFile, `{"filename":"logs/logxE/logx.log"}`)
  20. }
  21. func Println(format string, v ...interface{}) {
  22. if Test{fmt.Println(format, v)}
  23. logx.Info(format, v)
  24. }
  25. func PrintlnError(format string, v ...interface{}) {
  26. if Test{fmt.Println(format, v)}
  27. logxE.Error(format, v)
  28. logx.Info(format, v)
  29. }