code: def start_logging(out=_stdout, level='info'):
      
      global _log_level, _loggers, _started_logging
      if level not in log_levels:
          raise RuntimeError(
              "Invalid log level '{0}'; valid are: {1}".format(
                  level, ', '.join(log_levels)
              )
          )
  
      if _started_logging:
          return
  
      _started_logging = True
      _log_level = level
  
      handler = _TxaioFileHandler(out)
      logging.getLogger().addHandler(handler)
      # note: Don't need to call basicConfig() or similar, because we've
      # now added at least one handler to the root logger
      logging.raiseExceptions = True  # FIXME
      level_to_stdlib = {
          'critical': logging.CRITICAL,
          'error': logging.ERROR,
          'warn': logging.WARNING,
          'info': logging.INFO,
          'debug': logging.DEBUG,
          'trace': logging.DEBUG,
      }
      logging.getLogger().setLevel(level_to_stdlib[level])
      # make sure any loggers we created before now have their log-level
      # set (any created after now will get it from _log_level
      for logger in _loggers:
          logger._set_log_level(level)
docs: Begin logging.
  
      :param out: if provided, a file-like object to log to. By default, this is
                  stdout.
      :param level: the maximum log-level to emit (a string)