Turning On the Listener Log

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> ] [bufferedWrite:<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.

See File Access Function Search Behavior for a list of directories the filename_string is searched for if the full path is not specified.

EXAMPLE

openLog "my_log.txt"

or

logfile="my_log.txt"
openLog logfile

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.

EXAMPLE

openLog "my_log.txt" mode:"a" outputOnly:true

would append only the MAXScript output to file *my_log.txt* .

Available in 3ds Max 2017.1 Update and higher: By default, the log is written to an intermediate cache. If bufferedWrite is false, the log is written directly to disk. This may be useful when a crash is possible, for example when testing a new plug-in.

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:

flushLog()

You can stop logging, flush the log’s buffer, and close the log file using the closeLog() method:

closeLog()

No error message is generated if the flushLog() or closeLog() methods are called and no log file is open.

Use the getLog() function to get the log file name, if it has been created by openLog():

{<string>|<undefined>} getLog()