diff --git a/CmdLine.lua b/CmdLine.lua index d4f73fbd..23e99693 100644 --- a/CmdLine.lua +++ b/CmdLine.lua @@ -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("#", ...) diff --git a/doc/cmdline.md b/doc/cmdline.md index 7f34e28c..3f334397 100644 --- a/doc/cmdline.md +++ b/doc/cmdline.md @@ -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. ### option(name, default, help) ###