• Publicity: Public Only All

stack-trace-procs.tcl

Location:
packages/acs-tcl/tcl/stack-trace-procs.tcl
Created:
2000
Author:
bdolicki@branimir.com
CVS Identification:
$Id: stack-trace-procs.tcl,v 1.6 2024/09/11 06:15:48 gustafn Exp $

Procedures in this file

Detailed information

ad_log_stack_trace (public)

 ad_log_stack_trace

A wrapper for ad_print_stack_trace which does the logging for you.

Partial Call Graph (max 5 caller/called nodes):
%3 aa_selenium_init aa_selenium_init (private) ad_log_stack_trace ad_log_stack_trace aa_selenium_init->ad_log_stack_trace ad_print_stack_trace ad_print_stack_trace (public) ad_log_stack_trace->ad_print_stack_trace

Testcases:
No testcase defined.

ad_print_stack_trace (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 Also:

Partial Call Graph (max 5 caller/called nodes):
%3 ad_log_stack_trace ad_log_stack_trace (public) ad_print_stack_trace ad_print_stack_trace ad_log_stack_trace->ad_print_stack_trace callback callback (public) callback->ad_print_stack_trace search::dequeue search::dequeue (public) search::dequeue->ad_print_stack_trace search::indexer search::indexer (private) search::indexer->ad_print_stack_trace search::queue search::queue (public) search::queue->ad_print_stack_trace

Testcases:
No testcase defined.
[ hide source ] | [ make this the default ]

Content File Source

# stack-trace-procs.tcl
# (bdolicki 2000) - formerly known as StackTrace.tcl

# 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: stack-trace-procs.tcl,v 1.6 2024/09/11 06:15:48 gustafn Exp $
}


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 {
        if {$::errorInfo ne ""} {
            set callStack [list $::errorInfo "invoked from within"]
        } else {
            set callStack {}
        }
        for {set i [info level]} {$i > 0} {incr 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 -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]
}

# Local variables:
#    mode: tcl
#    tcl-indent-level: 4
#    indent-tabs-mode: nil
# End: