code: def log_to_stream(stream=sys.stderr, level=logging.NOTSET,
                    fmt=logging.BASIC_FORMAT):
      
      fmt = Formatter(fmt)
      handler = StreamHandler()
      handler.setFormatter(fmt)
      handler.setLevel(level)
  
      log.addHandler(handler)
docs: Add :class:`logging.StreamHandler` to logger which logs to a stream.
  
      :param stream. Stream to log to, default STDERR.
      :param level: Log level, default NOTSET.
      :param fmt: String with log format, default is BASIC_FORMAT.