Tk Library Source Code

View Ticket
Login
Ticket UUID: 1120152
Title: logger: maintain callstack for custom logprocs
Type: RFE Version: None
Submitter: hemanglavana Created on: 2005-02-10 16:49:25
Subsystem: log Assigned To: mic42
Priority: 5 Medium Severity:
Status: Closed Last Modified: 2005-09-23 23:50:44
Resolution: Closed By: mic42
    Closed on: 2005-09-23 16:50:44
Description:
Hi,

In logger package, custom logprocs should be able to
use "uplevel 1 .." to execute code in the caller's
scope. This currently works but is not documented.
There are several benefits for providing this feature,
such as:

* The default logger output does not include the caller
proc which is very useful. So I have defined a custom
logproc which uses [info level $lvl] cmd to get the
caller proc name.

* Execute code in caller's stack using uplevel cmd.
Instead of writing if stmts:

if {log::currentloglevel == "debug"} {
    log::debug "diagnosis = [runDiag $a]"
}

I prefer calling it as:

log::debug {diagnosis = [runDiag $a]}

and let custom proc for log::debug invoke [runDiag $a]
in the caller's scope and print/log the output returned
by it.

Hemang.
User Comments: mic42 added on 2005-09-23 23:50:44:
Logged In: YES 
user_id=302287

Added a section about this to the documentation.

mic42 added on 2005-02-19 08:40:50:
Logged In: YES 
user_id=302287

I added tests (14.x) for this feature and will add it to the
documentation for the next release.