Changeset 11:433f7e61f9f3 for src/logger.py
- Timestamp:
- 02/08/12 16:28:21 (13 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/logger.py
r9 r11 12 12 class Logger(object): 13 13 """The class with the interface to log the various events.""" 14 # FIXME: shall we use const.stage2string() instead? 14 15 _stages = { const.STAGE_BOARDING : "Boarding", 15 16 const.STAGE_PUSHANDTAXI : "Pushback and Taxi", … … 25 26 const.STAGE_END : "End" } 26 27 28 _noGoScore = 10000 29 27 30 def __init__(self, output = sys.stdout): 28 31 """Construct the logger.""" 29 self._ score = 100.032 self._faults = {} 30 33 self._output = output 31 34 … … 51 54 self.message(timestamp, "--- %s ---" % (s,)) 52 55 53 def fault(self, timestamp, what, score): 54 """Report a fault.""" 55 self._score -= score 56 self.message(timestamp, "%s (%f)" % (what, score)) 56 def fault(self, faultID, timestamp, what, score): 57 """Report a fault. 57 58 58 def noGo(self, timestamp, what): 59 faultID as a unique ID for the given kind of fault. If another fault of 60 this ID has been reported earlier, it will be reported again only if 61 the score is greater than last time. This ID can be, e.g. the checker 62 the report comes from.""" 63 if faultID in self._faults: 64 if score<=self._faults[faultID]: 65 return 66 self._faults[faultID] = score 67 if score==Logger._noGoScore: 68 self.message(timestamp, "%s (NO GO)" % (what)) 69 else: 70 self.message(timestamp, "%s (%f)" % (what, score)) 71 72 def noGo(self, faultID, timestamp, what, shortReason): 59 73 """Report a No-Go fault.""" 60 self._score = -1 61 self.message(timestamp, "%s (NO GO)" % (what,)) 74 self.fault(faultID, timestamp, what, Logger._noGoScore) 62 75 63 76 #--------------------------------------------------------------------------------------
Note:
See TracChangeset
for help on using the changeset viewer.