One big thing I learned from the C# port was the concept of logging: write output to a file; have a common function write_log(“something”) that creates a plaintext file nearby. This can be read, mailed, filtered and archived. A lot of times – gdb notwithstanding – I have to reproduce bugs. Having a trace log helps me narrow the problem to the last set of lines.
proc write_stamped_log {msg} { set log_path [file join [file dirname [info script] err.log]] set fh [open $log_path a]; # append puts $fh $msg close $fh }