def adapt_logger(logger):
  """
  Adapt our custom logger.BaseLogger object into a standard logging.Logger object.

  Adaptations are:
    - NoOpLogger turns into a logger with a single NullHandler.
    - SimpleLogger turns into a logger with a StreamHandler and level.

  Args:
    logger: Possibly a logger.BaseLogger, or a standard python logging.Logger.

  Returns: a standard python logging.Logger.

  """
  if isinstance(logger, logging.Logger):
    return logger

  # Use the standard python logger created by these classes.
  if isinstance(logger, (SimpleLogger, NoOpLogger)):
    return logger.logger

  # Otherwise, return whatever we were given because we can't adapt.
  return logger
Adapt our custom logger.BaseLogger object into a standard logging.Logger object.

  Adaptations are:
    - NoOpLogger turns into a logger with a single NullHandler.
    - SimpleLogger turns into a logger with a StreamHandler and level.

  Args:
    logger: Possibly a logger.BaseLogger, or a standard python logging.Logger.

  Returns: a standard python logging.Logger.