import datetime class LogList(): def __init__(self): self.log_list = list() self.read_index = 0 def add_item(self,*args): args = [str(i) for i in args] item = " ".join(args) item = str(datetime.datetime.now())+" "+str(item) self.log_list.append(item) if len(self.log_list) > 100: self.log_list.pop(0) def get_log_list(self): return self.log_list def get_new_items(self): items = self.log_list[self.read_index:] self.read_index = len(self.log_list) return items _log_handler = None def get_log_handler(): global _log_handler if not _log_handler: _log_handler = LogList() return _log_handler