Tcl Library Source Code

View Ticket
Login
Ticket UUID: 3065746
Title: formatted log::log for performence
Type: RFE Version: None
Submitter: oehhar Created on: 2010-09-14 06:56:01
Subsystem: log Assigned To: andreas_kupries
Priority: 3 Low Severity:
Status: Open Last Modified: 2011-05-11 15:47:06
Resolution: Closed By:
    Closed on:
Description:
Propose to add a command:
log::logf Level Formatpattern ?arg1? ?arg2? ?arg3?
which is equal in functionality to:
log::log Level [format Formatpattern ?arg1? ?arg2? ?arg3?]
for performence reasons.
Example:
Current solution to log a variable contents:
(1) log::log debug "Variable V=$V"
Proposed solution:
(2) log:logf debug "Variable V=%s" $V
If log level "debug" is activated, there is little difference.
If log level "debug" is not activated, (1) will still compose the log string, (2) will not.
For complex cases, this might be a considerable performence difference.
User Comments: oehhar added on 2011-05-11 15:47:06:
Indeed, subst gives more power than format.

format would be similar how the msgcat package handles things.

andreas_kupries added on 2010-09-16 05:55:25:
A more standard way would be, I believe, to use [subst] internally, not [format]. That way we just have to change "..."-quoting to {...}-quoting  (and, of course, change the name of the log command).
Alternatively, keep the name, i.e. "log", then this is a major API  change, forcing a major version change, i.e. 1.3 -> 2.

The subst is certainly what wub's Debug package does.