Welcome! Log In Create A New Profile


System.out.println considered harmful

Posted by Adrian Bowyer 
System.out.println considered harmful
September 12, 2007 04:45PM
I've added a class (org.reprap.utilities.Debug) that handles all debugging information.

Including that in a file, then making a call to the static function Debug.d(String) will print the string to System.out if debugging is turned on, together with a timestamp. Thus you get things like:

DEBUG: X axis - setting maximum torque to: 100 [0.317s/91ms]

The timestamp [0.317s/91ms] is the elapsed time since the first call to Debug in seconds, and the difference in time between this call and the last in ms.

A similar call to Debug.c(String) handles all the communications debugging:

comms: tx 0->2: e 44 [0.318s/1ms]
comms: rx: 54 52 30 0 2 bd [0.348s/30ms]

The difference in case is to make the two easier to distinguish when both are turned on.

Could we avoid writing anything to System.out in future, and instead call Debug.d?

Writing to System.err for actual errors is fine, of course.

Er -- debug information and complaints to me...

Edited 1 time(s). Last edit at 09/12/2007 04:47PM by Adrian Bowyer.

best wishes


Anonymous User
Re: System.out.println considered harmful
September 22, 2007 07:02AM
hi adrian,

the timing information is very nice and helpfull!
and the debug-class is of course a good improvement too.

Sorry, only registered users may post in this forum.

Click here to login