#!/usr/local/bin/python from threading import Lock class list_log: """ Provide an interface that lets logger.StreamHandler s write to a list of strings. """ def __init__(self, l=[]): """ Link to an existing list or just create a log """ self.ll = l self.lock = Lock() def write(self, str): """ Add the string to the log. Lock for consistency. """ self.lock.acquire() self.ll.append(str) self.lock.release() def flush(self): """ No-op that StreamHandlers expect """ pass