Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#323 formatted log::log for performence

open
log (11)
3
2010-09-14
2010-09-14
Harald Oehlmann
No

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.

Discussion

  • 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.

     
  • Indeed, subst gives more power than format.

    format would be similar how the msgcat package handles things.