Skip to content

Commit

Permalink
Make CmdLine:log check whether file is a file descriptor, before crea…
Browse files Browse the repository at this point in the history
…ting a new file (torch#690)

* Make CmdLine:log check whether file is a file descriptor, before creating a new file.
  • Loading branch information
cpuhrsch authored and soumith committed May 25, 2016
1 parent bfa7fc8 commit 7fc533e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CmdLine.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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("#", ...)
Expand Down
3 changes: 2 additions & 1 deletion doc/cmdline.md
Original file line number Diff line number Diff line change
Expand Up @@ -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) ###
Expand Down

0 comments on commit 7fc533e

Please sign in to comment.