While you work in Listener, you can use the Listener logging feature to capture your entered text and all printed output into a text file. Only text entered in either pane and printed output to the output pane is captured. Macro Recorder output is not captured. You turn on logging with the openLog() method.
openLog <filename_string> [ mode: "w" | "a" ] [ outputOnly:<boolean> ]
where <filename_string> is a string literal or an expression that evaluates to a string, and specifies the name of the log file to be created.
The default mode (mode:"w") creates a new file or overwrites an existing file. To append the log results to an existing file; specify mode:"a". If the specified file does not exist, an error message will be generated. Both input and output are logged by default; specify outputOnly:true to log only MAXScript output.
openLog "my_log.txt" mode:"a" outputOnly:true
would append only the MAXScript output to file my_log.txt.
If a log file is already open, the openlog() method will close that log file.
MAXScript echoes Listener activity as it occurs to the log file until you stop logging. The log file data is not continuously written to the file, rather the log data is written to a buffer in memory, and when the buffer is full the data in the buffer is written to the file. You can use the flushLog() method to ensure the log's buffer is flushed so that all output is written to the file:
You can stop logging, flush the log’s buffer, and close the log file using the closeLog() method:
No error message is generated if the flushLog() or closeLog() methods are called and no log file is open.