Tcl Library Source Code

View Ticket
Login
Ticket UUID: 19607f927b68c8d98d385ccb2efa7bdb2f86669e
Title: add log::logsubst to optimize logging of expensive to build messages
Type: RFE Version: trunk
Submitter: oehhar Created on: 2018-02-19 15:06:11
Subsystem: log Assigned To: aku
Priority: 8 Severity: Minor
Status: Closed Last Modified: 2018-05-18 04:17:01
Resolution: Accepted Closed By: aku
    Closed on: 2018-05-18 04:17:01
Description:

It might be expensive to build a log message:

log::log debug "XML of node $Node is '[$node asXml]'"

An extensive xml representation is build for log purposes and thrown away if not logged.

It is proposed to add a command logsubst, to do variable and command expansion only in the log case:

log::logsubst debug {XML of node $Node is '[$node asXml]'}

The substitution is done within the log command only if debug log level is set.

Implementation starting with commit [ec9cf4bb6f] in branch [rfe-19607f927b-logeval].

A practical usage is tclws (where the upper examples come from). The following commit introduces this optimisation and includes an emulator for older tcllib log packages:

https://core.tcl.tk/tclws/info/150950db68b9163a

User Comments: aku added on 2018-05-18 04:17:01:

All good, merged with commit [ea802e332b].


aku added on 2018-05-17 19:42:51:
Looks good. TODO (self): Run tests, validate docs, merge on success.

aku added on 2018-03-15 16:49:50:
Taking for review ...