Debugging scripts

By default, all script-related logging is done using the autoscript logger. Each script can be configured at different log levels like DEBUG, INFO, ERROR, and so on. The default setup for any script is at ERROR.

For example, assume you want to debug the following script:
y=float(iplr)+float(olr)
if y!=float(plr):
  pnr=str(y)
You put the following debug statements:
print "iplr="+iplr
print "olr="+olr
y=float(iplr)+float(olr)
print "y="+y
if y!=float(plr):
  pnr=str(y)
  print “pnr=”+pnr

You must make sure that the log level for the autoscript logger is set to the log level of the script. For example, set both of them to INFO. This will result in the print statements to show up in your systemout log. If required, the log statements produced by this logger can be re-directed to a dedicated log file holding only script-related log statements. The syntax of the print statement depends upon which language the script is being written with. Also, if the autoscript logger is set to ERROR level logs only, then the print statements inside the automation script are not written to a log file.

The scripting framework logs information after the script completes. This does not create an ideal debugging session, especially for long running scripts. Use the service.log set of APIs to log while the script is running. You can set the logger at the individual script scope. Create a logger with the script name and set the log level accordingly.

The base automation script logger is set at ERROR level. Set the script ABC log level to INFO from the Automation Scripts application. Use the following script code:
service.log("hey there - I am in Asset "+mbo.getString("assetnum"))

Bind this script to the ASSET init event using the object launch point. When you initialize assets, for example, from the list table in ASSET application, you see this log in near real time. However, other scripts would not show any logs as the logger is set only for the ABC script.