Skip to content

Commit dbb2291

Browse files
committed
logging: clean up log_cmd output when it prints out running time
Signed-off-by: Øyvind Harboe <[email protected]>
1 parent c52d235 commit dbb2291

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

flow/scripts/util.tcl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
proc log_cmd {cmd args} {
22
# log the command, escape arguments with spaces
3-
puts -nonewline "$cmd[join [lmap arg $args {format " %s" [expr {[string match {* *} $arg] ? "\"$arg\"" : "$arg"}]}] ""]"
3+
set log_cmd "$cmd[join [lmap arg $args {format " %s" [expr {[string match {* *} $arg] ? "\"$arg\"" : "$arg"}]}] ""]"
4+
puts $log_cmd
45
set start [clock seconds]
56
$cmd {*}$args
67
set time [expr {[clock seconds] - $start}]
78
if {$time >= 5} {
8-
puts -nonewline " ($time seconds)"
9+
# Ideally we'd use a single line, but the command can output text
10+
# and we don't want to mix it with the log, so output the time it took afterwards.
11+
puts "Took $time seconds: $log_cmd"
912
}
1013
puts ""
1114
}

0 commit comments

Comments
 (0)