<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def check_log(logfile, exited='Exited with exit code', successful='Successfully completed', exists=True):
 """ Often logfile doesn't exist because the job hasn't begun Parameters logfile : str String with path to logfile exists : bool Is the logfile required to exist exited : str String in logfile used to determine if a job exited. successful : str String in logfile used to determine if a job succeeded. """

    if not os.path.exists(logfile):
        return not exists

    if exited in open(logfile).read():
        return 'Exited'
    elif successful in open(logfile).read():
        return 'Successful'
    else:
        return 'None'