Ignore:
Timestamp:
04/21/12 11:13:29 (12 years ago)
Author:
István Váradi <ivaradi@…>
Branch:
default
hg-Phase:
(<MercurialRepository 1 'hg:/home/ivaradi/mlx/hg' '/'>, 'public')
Message:

The contents of log lines can be modified after they are written, and we are using it for Vref

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/mlx/logger.py

    r87 r96  
    2828    NO_GO_SCORE = 10000
    2929
    30     def __init__(self, output = sys.stdout):
     30    def __init__(self, output):
    3131        """Construct the logger."""
     32        self._lines = []
    3233        self._faults = {}
    3334        self._output = output
     
    4243
    4344        The faults logged so far will be cleared."""
     45        self._lines = []
    4446        self._faults.clear()
    4547               
     
    4749        """Put a simple textual message into the log with the given timestamp."""
    4850        timeStr = Logger._getTimeStr(timestamp)
    49         print >> self._output, timeStr + ":", msg
     51        return self._logLine(msg, timeStr)
    5052
    5153    def untimedMessage(self, msg):
    5254        """Put an untimed message into the log."""
    53         print >> self._output, msg
     55        return self._logLine(msg)
    5456
    5557    def debug(self, msg):
     
    9395                totalScore -= score
    9496        return totalScore
     97
     98    def updateLine(self, index, line):
     99        """Update the line at the given index with the given string."""
     100        (timeStr, _line) = self._lines[index]
     101        self._lines[index] = (timeStr, line)
     102        self._output.updateFlightLogLine(index, timeStr, line)
     103
     104    def _logLine(self, line, timeStr = None):
     105        """Log the given line."""
     106        index = len(self._lines)
     107        self._lines.append((timeStr, line))
     108        self._output.addFlightLogLine(timeStr, line)
     109        return index
    95110       
    96111#--------------------------------------------------------------------------------------
Note: See TracChangeset for help on using the changeset viewer.