class_docstr: Context manager to capture and suppress expected log output.
  
  Useful to make tests of error conditions less noisy, while still
  leaving unexpected log entries visible.  *Not thread safe.*
  
  The attribute ``logged_stack`` is set to true if any exception
  stack trace was logged.
  
  Usage::
  
      with ExpectLog('tornado.application', "Uncaught exception"):
          error_response = self.fetch("/some_page")
  
  .. versionchanged:: 4.3
     Added the ``logged_stack`` attribute.
docstr: 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.
docstr_tok: ["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","."]
code: def __init__(self, logger, regex, required=True):
      """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.
      """
      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
  
imports: from __future__ import absolute_import, division, print_function
  from tornado.log import gen_log, app_log
  from tornado.stack_context import ExceptionStackContext
  from tornado.util import raise_exc_info, basestring_type, PY3
  import functools
  import inspect
  import logging
  import os
  import re
  import signal
  import socket
  import sys
label_desc: Use image node_id 1 to create a new ExpectLog object from inherited base classes: logging with example: obj = ExpectLog(logger, regex, required)