'Constructs an ExpectLog context manager.
:param logger: Logger object (or name of logger) to watch.  Pass
an empty string to watch the root logger.
:param regex: Regular expression to match.  Any log entries on
the specified logger that match this regex will be suppressed.
:param required: If true, an exception will be raised if the end of
the ``with`` statement is reached without matching any log entries.'

def __init__(self, logger, regex, required=True):

    if isinstance(logger, basestring_type):
        logger = logging.getLogger(logger)
    self.logger = logger
    self.regex = re.compile(regex)
    self.required = required
    self.matched = False
    self.logged_stack = False
