jel88
jel88

Reputation: 35

How to print TCL run commands

How to print each TCL command I am running , ideally how can I customize this print ?

i.e :

>> namespaceXY::commandXY

I would like to print :

"-- Running : namespaceXY::commandXY"

Thanks

Upvotes: 0

Views: 1921

Answers (1)

Donal Fellows
Donal Fellows

Reputation: 137567

To see a trace of commands, use an execution trace. You usually attach those to something like source or (less commonly) eval.

proc printTrace {commandCall op} {
    # I don't know whether you want the arguments too; they can get quite long...
    puts "-- Running : [lindex $commandCall 0]"
}
trace add execution source enterstep printTrace
source myScript.tcl

That will enable tracing of all commands from when the source starts to when it finishes; if that file includes your main loop processing, you'll get a print of absolutely everything.

Note that step-level execution tracing has a substantial overhead, and that some commands may have internal steps that you don't normally observe.

Upvotes: 3

Related Questions