Homepage › Clovertech Forums › Read Only Archives › Cloverleaf › Cloverleaf › tcl program standards › Reply To: tcl program standards
You didn’t exactly ask this question but here’s an answer anyway; should you use ‘puts’ or ‘echo’? Over time, the core TCL commands have been optimized more than the extended commands so you should use core commands over extended commands when possible. ‘echo’ is an extended command and ‘puts’ is a core command. In my own code I’ve started using ‘puts’. This doesn’t mean that you should go change all your ‘echo’s in to ‘puts’ in your old code, it just means, in programmer-ese, you get some slight benefit for using ‘puts’.
On the other question about a standard way to put messages into the log, I have my own technique and so do many others. Quovadx has pretty much kept hands off when it comes to coding technique. I present my ideas in classes but each implementer has their own variations.
There is a standard procedure called ‘dputs’ that you can run to do logging. Go into a ‘hcitcl’ sessoin in a shell and type ‘dputs’. It’s cool in that if the debug variable either doesn’t exist or is 0 then the procedure redefines itself to be a no-op. You’ll have to go poke around in the Cloverleaf TCL library directory to find the procedure.
I have my own technique because I wanted my log entry to have more info than what ‘dputs’ has. I call mine ‘dEcho’ (even though it uses ‘puts’).
Either way, my print to the log statements stay in my code and I turn them on or off using a debug variable. That way when I go to production I set the variable to 0. When I want debugging then I set the variable to 1.
Cheers,