I'm writing some scripts in ActionScript to automate some tasks in Adobe Indesign 2019 (part of the Creative Cloud Suite), but this applies to all scripting for all applications in Adobe Creative Cloud.
I don't want to use ExtendScript Toolkit for editing/running the script, because it is terribly slow.
Because there is no such thing as console.log()
available (at least that I'm aware of) and alert()
will stop for user input to continue, I created a small file logger, but it does not append the file, but keeps on overwriting the first line. I use tail -f indesign.log
to monitor the log file.
Here is the code of the logger
function logger(message){
var logFilePath = new File ('indesign.log');
logFilePath.encoding = 'UTF-8';
try {
logFilePath.open('a');
}
catch(err) {
logFilePath.close();
logFilePath.open('a');
}
logFilePath.write(new Date().toLocaleString() +": " + message + "\n");
//logFilePath.writeln(new Date().toLocaleString() +": " + message + "\n");
logFilePath.close()
}
logger("Script started")
logger("2nd line")
logger("3rd line")
logger("4th line")
logger("Script finished")
I tried also using writeln
instead of write
, but it does not make a difference.
I tried different line feeds, like "\n"
and "\r\n"
, but it does not make a difference.
I tried different File.open
options like .open('w')
, .open('ra')
. The documentation about this is either not clear or really outdated (Or I just can't find it).
Any suggestions in the comments about the best IDE to edit/run ActionScripts is highly appreciated.