-- 将日志信息写入文件中
function writeLog2File(msg)
if cc.Application:getInstance():getTargetPlatform() == cc.PLATFORM_OS_WINDOWS then -- win
local logFilePath = cc.FileUtils:getInstance():getWritablePath() .. "debug_log.txt"
io.writefile(logFilePath , string.format("%s: %s\n", os.date(), msg), "a+")
end
end
-- 删除本地文件
function deleteLogFile()
if cc.Application:getInstance():getTargetPlatform() ~= cc.PLATFORM_OS_WINDOWS then return end
local logFilePath = cc.FileUtils:getInstance():getWritablePath() .. "debug_log.txt"
local isExist = cc.FileUtils:getInstance():isFileExist(logFilePath)
if isExist then
cc.FileUtils:getInstance():removeFile(logFilePath)
end
end
deleteLogFile()