Permalink
Browse files

Make CmdLine:log check whether file is a file descriptor, before crea…

…ting a new file (#690)

* Make CmdLine:log check whether file is a file descriptor, before creating a new file.
  • Loading branch information...
1 parent bfa7fc8 commit 7fc533eb8f9f55ba83db256c811667c347e6bb1a @cpuhrsch cpuhrsch committed with soumith May 25, 2016
Showing with 3 additions and 2 deletions.
  1. +1 −1 CmdLine.lua
  2. +2 −1 doc/cmdline.md
View
@@ -189,7 +189,7 @@ end
local oprint = nil
function CmdLine:log(file, params)
- local f = io.open(file, 'w')
+ local f = (io.type(file) == 'file' and file) or io.open(file, 'w')
oprint = oprint or print -- get the current print function lazily
function print(...)
local n = select("#", ...)
View
@@ -107,7 +107,8 @@ The final produced output for the following command is:
### log(filename, parameter_table) ###
It sets the log filename to `filename` and prints the values of
-parameters in the `parameter_table`.
+parameters in the `parameter_table`. If filename is an open file
+descriptor, it will write to the file instead of creating a new one.
<a name="torch.CmdLine.option"></a>
### option(name, default, help) ###

0 comments on commit 7fc533e

Please sign in to comment.