<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def get_plain_logname(base_name, root_dir, enable_json):
 """ we nest all plain logs to prevent double log shipping """

    if enable_json:
        nested_dir = os.path.join(root_dir, 'plain')
        if os.path.exists(root_dir) and not os.path.exists(nested_dir):
            os.mkdir(nested_dir)
        root_dir = nested_dir
    return os.path.join(root_dir, '{}.log'.format(base_name))