<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 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