'Context manager to temporarily log messages to a list.
Parameters
filename : str
The file to log messages to.
filter_level : str
If set, any log messages less important than ``filter_level`` will
not be output to the file. Note that this is in addition to the
top-level filtering for the logger, so if the logger has level
\'INFO\', then setting ``filter_level`` to ``INFO`` or ``DEBUG``
will have no effect, since these messages are already filtered
out.
filter_origin : str
If set, only log messages with an origin starting with
``filter_origin`` will be output to the file.
Notes
Using this context manager does not stop log messages from being
output to standard output.
Examples
The context manager is used as::
with logger.log_to_list() as log_list:
# your code here'

@contextmanager
def log_to_list(self, filter_level=None, filter_origin=None):

    lh = ListHandler()
    if (filter_level is not None):
        lh.setLevel(filter_level)
    if (filter_origin is not None):
        lh.addFilter(FilterOrigin(filter_origin))
    self.addHandler(lh)
    (yield lh.log_list)
    self.removeHandler(lh)
