docs: def capture_logger(name):
      """ Context manager to capture a logger output with a StringIO stream.
      """
      import logging
  
      logger = logging.getLogger(name)
      try:
          import StringIO
          stream = StringIO.StringIO()
      except ImportError:
          from io import StringIO
          stream = StringIO()
      handler = logging.StreamHandler(stream)
      logger.addHandler(handler)
      try:
          yield stream
      finally:
          logger.removeHandler(handler)