LogPrintln.go 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. package logs
  2. import (
  3. "Cold_Api/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","color":true,"Perm":"777"}`)
  10. logx.EnableFuncCallDepth(true)
  11. logx.SetLogFuncCallDepth(3)
  12. logx.SetLevel(logs.LevelInformational)
  13. if conf.RunMode == "dev" {
  14. logx.SetLevel(logs.LevelDebug)
  15. logx.SetLogger(logs.AdapterConsole)
  16. }
  17. }
  18. func PPrintln(format string, v ...interface{}) {
  19. for _, _ = range v {
  20. format += " %v"
  21. }
  22. logx.Info(format, v...)
  23. }
  24. // Debug Log DEBUG level message.
  25. func DDebug(format string, v ...interface{}) {
  26. for _, _ = range v {
  27. format += " %v"
  28. }
  29. logx.Debug(format, v...)
  30. }
  31. // Info Log ERROR level message.
  32. func IInfo(format string, v ...interface{}) {
  33. for _, _ = range v {
  34. format += " %v"
  35. }
  36. logx.Info(format, v...)
  37. }
  38. // Error Log ERROR level message.
  39. func EError(format string, v ...interface{}) {
  40. for _, _ = range v {
  41. format += " %v"
  42. }
  43. logx.Error(format, v...)
  44. }
  45. // Warning Log WARNING level message.
  46. func WWarning(format string, v ...interface{}) {
  47. for _, _ = range v {
  48. format += " %v"
  49. }
  50. logx.Warning(format, v...)
  51. }