Menu

#508 bad multiple calls to logging command in log::log

open
log (10)
5
2004-08-26
2004-08-13
No

When the text to log consists of multiple lines, this
results in calling the logging command as many times as
there are lines.

After inspecting the code, I saw that around line 672
(in tcllib release 1.6), a change has been introduced
to correctly handle log texts that consist of multiple
lines.

The relevant code snippet is:

foreach line [split $text \n] {
eval [linsert $cmd end $level $line]
}

This causes the logging command to be called repeatedly
for a single log text (which did not happen in the log
extension that resided in tcllib release 1.3 for example).

Discussion

  • Andreas Kupries

    Andreas Kupries - 2004-08-13

    Logged In: YES
    user_id=75003

    How is having one call per line bad ? This means that each
    line is (correctly) prefixed with the level, for example (if
    using the standard proc).

     
  • Erik Leunissen

    Erik Leunissen - 2004-08-13

    Logged In: YES
    user_id=113903

    Good or bad is of course a matter of taste.

    I expect a call to [log:log] log a _single event_ to the log
    file. If this expectation is wrong than please indicate what
    I should expect.

    If the event to be logged happens to be annotated with a
    text containing multiple lines, I end up with a log file
    whose (distorted) format implies multiple events.

    Of course, I may have been abusing [log::log] all the time ....

    Example:
    An app walks into a bgerror (a single event ! ), which is
    captured and logged as follows:

    proc bgerror {} {
    global errorInfo
    .....
    # note that $errorInfo has multiple lines ...
    log::log $level $errorInfo
    .....
    }

     
  • Andreas Kupries

    Andreas Kupries - 2004-08-26

    Logged In: YES
    user_id=75003

    We never specified in the beginning how much a call to
    log::log should write, and the interface to the log command
    itself was unspecified in this regard as well.

    I'll have to think more about this.

     
  • Andreas Kupries

    Andreas Kupries - 2004-08-26
    • labels: --> log
    • assigned_to: nobody --> andreas_kupries