Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/torch/xlua.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSoumith Chintala <soumith@gmail.com>2015-10-22 01:27:27 +0300
committerSoumith Chintala <soumith@gmail.com>2015-10-22 01:27:27 +0300
commit0a542bb78f54259b4bad594b279a1914351caae6 (patch)
tree6a939db28d205e771df31718fd1f654dc070b913
parent91a786b830ccf4004a8d0162653ab782dd25c1a1 (diff)
parent75a79a7f76ee446cfc69097e0b5aca0602140346 (diff)
Merge pull request #10 from mranzinger/patch-1
Allow xlua.log to optionally append to an existing file instead of overwriting
-rw-r--r--init.lua8
1 files 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