LogPrintln.go 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. package logs
  2. import (
  3. "ColdP_server/conf"
  4. "github.com/astaxie/beego/logs"
  5. "runtime"
  6. )
  7. var logx *logs.BeeLogger
  8. var Test = true
  9. func init() {
  10. logx = logs.NewLogger()
  11. logx.SetLogger(logs.AdapterFile, `{"filename":"logs/logx/logx.log"}`)
  12. logx.EnableFuncCallDepth(true)
  13. logx.SetLogFuncCallDepth(3)
  14. if conf.RunMode == "dev" {
  15. logx.SetLogger("console")
  16. }
  17. if runtime.GOOS == "windows" {
  18. Test = true
  19. } else {
  20. Test = false
  21. }
  22. }
  23. func Println(format string, v ...interface{}) {
  24. for _, _ = range v {
  25. format += " %v"
  26. }
  27. logx.Info(format, v...)
  28. }
  29. // Debug Log DEBUG level message.
  30. func Debug(format string, v ...interface{}) {
  31. for _, _ = range v {
  32. format += " %v"
  33. }
  34. logx.Debug(format, v...)
  35. }
  36. // Info Log ERROR level message.
  37. func Info(format string, v ...interface{}) {
  38. for _, _ = range v {
  39. format += " %v"
  40. }
  41. logx.Info(format, v...)
  42. }
  43. // Error Log ERROR level message.
  44. func Error(format string, v ...interface{}) {
  45. for _, _ = range v {
  46. format += " %v"
  47. }
  48. logx.Error(format, v...)
  49. }
  50. // Warning Log WARNING level message.
  51. func Warning(format string, v ...interface{}) {
  52. for _, _ = range v {
  53. format += " %v"
  54. }
  55. logx.Warning(format, v...)
  56. }