Menu

#323 formatted log::log for performence

open
log (11)
3
2010-09-14
2010-09-14
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

  • Andreas Kupries

    Andreas Kupries - 2010-09-15

    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.

     
  • Harald Oehlmann

    Harald Oehlmann - 2011-05-11

    Indeed, subst gives more power than format.

    format would be similar how the msgcat package handles things.

     
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.