From 75a79a7f76ee446cfc69097e0b5aca0602140346 Mon Sep 17 00:00:00 2001 From: mranzinger Date: Wed, 21 Oct 2015 15:45:14 -0600 Subject: Update init.lua Allowing the logfile to be appended to instead of just overwritten. --- init.lua | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/init.lua b/init.lua index 2eb1630..6ad5f60 100644 --- a/init.lua +++ b/init.lua @@ -109,9 +109,11 @@ rawset(_G, 'xprint', xlua.print) ---------------------------------------------------------------------- -- log all session, by replicating stdout to a file ---------------------------------------------------------------------- -function xlua.log(file) +function xlua.log(file, append) os.execute('mkdir ' .. (sys.uname() ~= 'windows' and '-p ' or '') .. ' "' .. sys.dirname(file) .. '"') - local f = assert(io.open(file,'w')) + local mode = 'w' + if append then mode = 'a' end + local f = assert(io.open(file,mode)) io._write = io.write _G._print = _G.print _G.print = xlua.print @@ -713,4 +715,4 @@ function string.tosymbol(str) end end -return xlua \ No newline at end of file +return xlua -- cgit v1.2.3