Monday, May 5, 2014

Debugging AppleScript: print to a file

Debugging AppleScript is easy when you work with the script editor, simply use log to print out anything in the console. However, after you compiled it to an app, this cannot work anymore.

I find there are several ways to do it in this thread. The two approaches that work best for me are:

  1. Use logger to log to the syslog. E.g.,
1  
do shell script "logger -t 'AS DEBUG' " & myObj  

However, I don't know why sometimes this is not logged. So I will use the following:

  1. Echo to file
1  2  
do shell script "echo " & quoted form of (myObj as string) & ¬      " >> ~/Desktop/as_debug.txt"  


via Zigang Xiao http://bit.ly/1nWnLGH

No comments: