Index: openacs-4/packages/acs-tcl/tcl/stack-trace-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/stack-trace-procs.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/acs-tcl/tcl/stack-trace-procs.tcl 3 Feb 2005 18:21:21 -0000 1.1 +++ openacs-4/packages/acs-tcl/tcl/stack-trace-procs.tcl 17 Feb 2005 15:12:58 -0000 1.2 @@ -4,31 +4,45 @@ # Print stack trace after catch # Taken from http://photo.net/bboard/q-and-a-fetch-msg.tcl?msg_id=000kCh ad_library { - @author bdolicki@branimir.com - @creation-date 2000 - @cvs-id $Id$ + @author bdolicki@branimir.com + @creation-date 2000 + @cvs-id $Id$ } -ad_proc ad_print_stack_trace {} { - Formerly known as PrintStackTrace. This is useful if you use catch but - you'd still want to access the full Tcl stack trace (e.g. to dump it -into - the log file) +ad_proc -public ad_print_stack_trace {} { + Formerly known as PrintStackTrace. This is useful if you use catch but + you'd still want to access the full Tcl stack trace e.g. to dump it into + the log file + + This command truncatates the actual commands to improve readability + while ad_get_tcl_call_stack dumps the full stack + + @see ad_get_tcl_call_stack } { -uplevel { - global errorInfo - set callStack [list $errorInfo] - for {set i [info level]} {$i >= 0} {set i [expr $i - 1]} { - lappend callStack "invoked from within" - lappend callStack [info level $i] - } - return [join $callStack "\n"] + uplevel { + global errorInfo + if {![empty_string_p $errorInfo]} { + set callStack [list $errorInfo "invoked from within"] + } else { + set callStack {} + } + for {set i [info level]} {$i > 0} {set i [expr $i - 1]} { + set call [info level $i] + if {[string length $call] > 160} { + set call "[string range $call 0 150]..." } + regsub -all {\n} $call {\\n} call + lappend callStack " $call" + if {$i > 1} { + lappend callStack "invoked from within" + } + } + return [join $callStack "\n"] + } } -} -ad_proc ad_log_stack_trace {} { - A wrapper for ad_print_stack_trace which does the logging for you. +ad_proc -public ad_log_stack_trace {} { + A wrapper for ad_print_stack_trace which does the logging for you. } { - ns_log Error [ad_print_stack_trace] + ns_log Error [ad_print_stack_trace] }