def set_debug(self, debug=1):
        """
        Set the debug level.

        :type  debug: int
        :param debug: The debug level.
        """
        self._check_if_ready()
        self.debug = debug
        self.main_loop.debug = debug
Set the debug level.

        :type  debug: int
        :param debug: The debug level.