You have written a Google Wave Robot, uploaded it on AppEngine, and it does not seem to behave the way you expected?Â You would not be searching the Internet if it was working, would you?
First, you are not alone. The robot API appears to be changing, and I have observed changes in the amount of information my robots receive, over time. The best way to figure out what is going on with the robot is to look at the raw data sent by the Wave server to the robot. These messages are remote procedure calls encoded in JSON (jsonrpc).
This post assumes that the Google Wave Robot is deployed on AppEngine.Â At the time of writing this post, this is the only avenue for deploying Wave Robots.
To see the raw data transmitted to a Wave Robot, one must:
- Enable the robot to record FINEST log messages
- Capture the logs from the AppEngine web site
- Decode the JSON message in human readable format
This post deals with 1 and 3.
Enable FINEST logging
In your robot project, there is a properties file used to configure the logger. In general, this file is located in …/WEB-INF/logging.propertiesÂ This location can change, since it is declared in a file called …/WEB-INF/appengine-web.xml. If you can not find the logging properties files, inspect the appengine-web.xml file. It should look like this:
<?xml version="1.0" encoding="utf-8"?>
<!-- Configure java.util.logging -->
<property name="java.util.logging.config.file" value="WEB-INF/logging.properties"/>
If the system property called “java.util.logging.config.file” is not present, then you should add it and create the “logging.properties” file. If the property already exists, then you have a clue where the file can be found.
The “logging.properties” file should contain something as follows:
# A default java.util.logging configuration.
# (All App Engine logging is through java.util.logging by default).
# To use this configuration, copy it into your application's WEB-INF
# folder and add the following to your appengine-web.xml:
# <property name="java.util.logging.config.file" value="WEB-INF/logging.properties"/>
# Set the default logging level for all loggers to WARNING
.level = FINEST
# Set the default logging level for ORM, specifically, to WARNING
The trick is to change the property called “.level” to a value of “FINEST”. By default, most example give a value of “WARNING” to this property.
Once this change is done, upload the robot on AppEngine, again, for the new logging level to take effect.
Capturing the logs
Once the robot is uploaded on AppEngine, interacting with a wave that includes the robot should generate messages sent to it. Using the AppEngine administrative page for the robot, navigate to the “logs” page. Changing the filter to “INFO” should refresh the page with a number of “I” icons. Those are the information entries in the logs. Some of those should display the incoming events and outgoing operations.
Copy the large JSON object from the incoming events into the clip board.
Format JSON for a human
A number of online services will readily translate JSON to a more readable format. One of those is: http://jsonformatter.curiousconcept.com/ Pasting the content obtained in the previous step into the web form and formatting should give you the full picture of the information available to the robot.