源战役客户端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

83 lines
1.9 KiB

  1. LuaLogManager = LuaLogManager or BaseClass()
  2. local LuaLogManager = LuaLogManager
  3. function LuaLogManager:__init()
  4. LuaLogManager.Instance = self
  5. self.is_enable = true
  6. -- if SystemRuntimePlatform.IsWindowsEditor() then
  7. -- self.is_enable = false
  8. -- end
  9. self:SetLogEnable(self.is_enable)
  10. local old_print_func = _G.print
  11. _G.print = function ( ... )
  12. if RuntimePlatform and (SystemRuntimePlatform.IsAndroid() or SystemRuntimePlatform.IsIphone()) then
  13. return
  14. end
  15. self:Log(...)
  16. end
  17. end
  18. function LuaLogManager:getInstance()
  19. if LuaLogManager.Instance == nil then
  20. LuaLogManager.New()
  21. end
  22. return LuaLogManager.Instance
  23. end
  24. function LuaLogManager:__delete()
  25. end
  26. function LuaLogManager:PackageContent(...)
  27. local arg = {...}
  28. -- local printResult = "[".. TimeUtil:timeConversionWithMillisecond(TimeUtil:getServerTimeMs(), "hh:mm:ss.ms") .."] "
  29. local printResult = ""
  30. for i,v in pairs(arg) do
  31. printResult = printResult .. tostring(v) .. "\t"
  32. end
  33. return printResult
  34. end
  35. function LuaLogManager:SetLogEnable(value)
  36. if logMgr then
  37. logMgr.EnableLog = value
  38. end
  39. end
  40. function LuaLogManager:Log( ... )
  41. if RuntimePlatform and (SystemRuntimePlatform.IsAndroid() or SystemRuntimePlatform.IsIphone()) then
  42. return
  43. end
  44. if not self.is_enable then
  45. return
  46. end
  47. if logMgr then
  48. local printResult = self:PackageContent(...)
  49. logMgr.Log(printResult)
  50. end
  51. end
  52. --警告日志--
  53. function LuaLogManager:LogWarn( ... )
  54. if RuntimePlatform and (SystemRuntimePlatform.IsAndroid() or SystemRuntimePlatform.IsIphone()) then
  55. return
  56. end
  57. if not self.is_enable then
  58. return
  59. end
  60. if logMgr then
  61. local printResult = self:PackageContent(...)
  62. logMgr.LogWarning(printResult)
  63. end
  64. end
  65. --错误日志--
  66. function LuaLogManager:LogError( ... )
  67. if logMgr then
  68. local printResult = self:PackageContent(...)
  69. logMgr.LogError(printResult)
  70. GameError.Instance:SendErrorToPHP(printResult)
  71. end
  72. end