If you include code like:
printf("entity type is: %s\n",entity.class)
in your ruby scripts, then is will output messages to the ruby console.
By adding traceback information to messages, you can also display where the messages originated in your ruby code.
Using the Ruby caller() function, you can get information on who called a routine - either the immediate caller, or the full traceback.
- caller(1) - returns the callback information for the immediate, preceding caller.
This is a sample ruby file defining a routine trace(*args).
- trace() is used much like sprintf, except that it automatically adds information to display where in your code the message was displayed.
trace("4 + 1 = %s", 4+1)
# display a message with a trace back of where it originated
scall = caller(1).to_s # who called the routine
smess = sprintf(*args)
warn "arg ERROR in trace called from: " + caller(1).to_s
printf("%s\n\t(%s)\n", smess, scall)
Here test_trace.rb was loaded into the ruby console (user entries are in bold).
Notice how the source file and line number are displayed along with the trace information.
4 + 1 = 5
If there is an error in your Ruby Script, an error message will be displayed in the Ruby Console.
What are Ruby Scripts and Plugins?