|
看到有人反映C盘满了, 以后琢磨过一个少写log的方法。分享一下。
是在job.lua里,最后几个函数。
function scrLog()
local filename = GetInfo (67) .. "logs\\" .. score.id .. '发呆'..os.date("%Y%m%d_%H时%M分%S秒") .. ".log"
local file = io.open(filename,"w")
local t = {}
for i = 1,GetLinesInBufferCount() do
table.insert(t,GetLineInfo(i,1))
end
local s = table.concat(t,"\n") .. "\n"
file:write(s)
file:close()
end
function dieLog()
local filename = GetInfo (67) .. "logs\\" .. score.id .. '死亡'..os.date("%Y%m%d_%H时%M分%S秒") .. ".log"
local file = io.open(filename,"w")
local t = {}
for i = 1,GetLinesInBufferCount() do
table.insert(t,GetLineInfo(i,1))
end
local s = table.concat(t,"\n") .. "\n"
file:write(s)
file:close()
end
function jobfailLog()
--[[local filename = GetInfo (67) .. "logs\\" .. score.id .. '任务失败'..os.date("%Y%m%d_%H时%M分%S秒") .. ".log"
local file = io.open(filename,"w")
local t = {}
for i = 1,GetLinesInBufferCount() do
table.insert(t,GetLineInfo(i,1))
end
local s = table.concat(t,"\n") .. "\n"
file:write(s)
file:close()]]
end
|
|