# It will then be able to print all of them out.
def __init__ (self):
- self.__msg_dict = {}
+ self.__messages = []
- def __get_key (self, id):
- """__get_key (id) -> key"""
- # Get a valid key which will always be the same as any other similar key, even if
- # the actual memory reference is different.
- return str(id)
-
- def addMessage (self, id, msg, printquiet=True):
+ def addMessage (self, msg, printquiet=True):
# Add a message to the dictionary, to be printed later.
# The printquiet variable controls whether the message will be printed
# normally, or only in verbose mode. The default is to print always.
- # Get the key
- key = self.__get_key (id)
-
- # Create the dictionary entry if necessary
- if key not in self.__msg_dict.keys():
- self.__msg_dict[key] = []
-
- # Get the list from the dictionary, then add the message to it
- self.__msg_dict[key].append (RarslaveMessage (msg, printquiet))
+ self.__messages.append (RarslaveMessage (msg, printquiet))
def printAllMessages (self, verbose=False):
- # Print all messages in groups by id
- for k in self.__msg_dict.keys():
- for msg in self.__msg_dict[k]:
-
- # Skip verbose messages if we're not in verbose mode
- if msg.isVerbose() and not verbose:
- continue
-
- print msg
+ for msg in self.__messages:
+ # Skip verbose messages if we're not in verbose mode
+ if msg.isVerbose() and not verbose:
+ continue
- print
+ print msg
def main ():
- logger = RarslaveLogger ()
- logger.addMessage (1, 'hello 1')
- logger.addMessage (2, 'hello 2')
- logger.addMessage (2, 'world 2')
- logger.addMessage (1, 'world 1')
- logger.printAllMessages ()
+ pass
if __name__ == '__main__':
main ()