Automatically Include Revision in Log Statement

When there is a problem with your software, the first thing you usually ask for is a log showing what happened (provided you write debuggable code), and the version of the software that was running. But it is easy to have the revision of the software automatically added to the log.

In the class Call.java, the subversion revision number is automatically stored at every commit using the following syntax:

The first printed line in the log shows that the version of Call.java used was 135264. Every line in the log also contains a relative time stamp (in milliseconds) and the module name, in addition to the actual message. And yes, we still use subversion at work, but I am sure the same information can be included from git as well.

I have been using this simple addition to the logs for a long time, and it has been helpful many times in the past. Every time you check in a new version, the revision variable is updated automatically. If you are not already using this, give it a try. It is quick to set up, and you never again have to wonder which revision was used.