|
|
- LuaLogManager = LuaLogManager or BaseClass()
- local LuaLogManager = LuaLogManager
- function LuaLogManager:__init()
- LuaLogManager.Instance = self
-
- self.is_enable = true
- -- if SystemRuntimePlatform.IsWindowsEditor() then
- -- self.is_enable = false
- -- end
- self:SetLogEnable(self.is_enable)
- local old_print_func = _G.print
- _G.print = function ( ... )
- if RuntimePlatform and (SystemRuntimePlatform.IsAndroid() or SystemRuntimePlatform.IsIphone()) then
- return
- end
- self:Log(...)
- end
-
- end
-
- function LuaLogManager:getInstance()
- if LuaLogManager.Instance == nil then
- LuaLogManager.New()
- end
- return LuaLogManager.Instance
- end
-
- function LuaLogManager:__delete()
- end
-
- function LuaLogManager:PackageContent(...)
- local arg = {...}
- -- local printResult = "[".. TimeUtil:timeConversionWithMillisecond(TimeUtil:getServerTimeMs(), "hh:mm:ss.ms") .."] "
- local printResult = ""
- for i,v in pairs(arg) do
- printResult = printResult .. tostring(v) .. "\t"
- end
- return printResult
- end
-
- function LuaLogManager:SetLogEnable(value)
- if logMgr then
- logMgr.EnableLog = value
- end
- end
-
-
- function LuaLogManager:Log( ... )
- if RuntimePlatform and (SystemRuntimePlatform.IsAndroid() or SystemRuntimePlatform.IsIphone()) then
- return
- end
- if not self.is_enable then
- return
- end
- if logMgr then
- local printResult = self:PackageContent(...)
- logMgr.Log(printResult)
- end
- end
-
- --警告日志--
- function LuaLogManager:LogWarn( ... )
- if RuntimePlatform and (SystemRuntimePlatform.IsAndroid() or SystemRuntimePlatform.IsIphone()) then
- return
- end
- if not self.is_enable then
- return
- end
- if logMgr then
- local printResult = self:PackageContent(...)
- logMgr.LogWarning(printResult)
- end
- end
-
- --错误日志--
- function LuaLogManager:LogError( ... )
- if logMgr then
- local printResult = self:PackageContent(...)
- logMgr.LogError(printResult)
-
- GameError.Instance:SendErrorToPHP(printResult)
- end
- end
|