X-Git-Url: https://irasnyder.com/gitweb/?a=blobdiff_plain;f=RarslaveLogger.py;h=06b59a6cccb13e9ab60c158d03f5ee1ff763e83f;hb=38940fb246daaa0ebc7273e789bdcfbf5148a271;hp=83752f02c18a657fcacef5c29c10541a02ab761f;hpb=e33dad4f4feea215742be92a5a5ed21832275f39;p=rarslave2.git diff --git a/RarslaveLogger.py b/RarslaveLogger.py index 83752f0..06b59a6 100644 --- a/RarslaveLogger.py +++ b/RarslaveLogger.py @@ -19,49 +19,25 @@ class RarslaveLogger (object): # 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 ()