LogPrintln.go 1.1 KB

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