X-Git-Url: https://irasnyder.com/gitweb/?a=blobdiff_plain;f=RarslaveLogger.py;h=06b59a6cccb13e9ab60c158d03f5ee1ff763e83f;hb=38940fb246daaa0ebc7273e789bdcfbf5148a271;hp=bed18d46d0f82a2fa7cccbf432751c8e0157376c;hpb=0d1350faf4ae51b33f711f8a164943b8930ad228;p=rarslave2.git diff --git a/RarslaveLogger.py b/RarslaveLogger.py index bed18d4..06b59a6 100644 --- a/RarslaveLogger.py +++ b/RarslaveLogger.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# vim: set ts=4 sts=4 sw=4 textwidth=112: +# vim: set ts=4 sts=4 sw=4 textwidth=92: class RarslaveMessage (object): def __init__ (self, msg, printquiet): @@ -19,47 +19,22 @@ class RarslaveLogger (object): # It will then be able to print all of them out. def __init__ (self): - self.__uniq_num = 0 - self.__msg_dict = {} + self.__messages = [] - def getUniqueID (self): - # Generate a unique id. This implementation is pretty simple, - # just generating an increasing set of integers. - - # This function also sets up the dictionary which will hold the messages. - self.__uniq_num += 1 - self.__msg_dict[self.__uniq_num] = [] - - return self.__uniq_num - - def isValidID (self, id): - # Check if the id given is a valid one. This is done by checking if - # the id is in the dictionary. - return id in self.__msg_dict.keys() - - 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. - # Check the id - assert self.isValidID (id) - - # Get the list from the dictionary, then add the message to it - self.__msg_dict[id].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 (): pass