Handle Logging

def log_folder_setup(log_path, archive_logs=False):
    """ Handle Logging """
    if log_path.endswith("/"):
        log_path = log_path[:-1]
    if not os.path.exists(log_path):
        try:
            os.makedirs(log_path)
        except Exception:
            pass  # Should only be reachable during multi-threaded runs
    else:
        archived_folder = "%s/../archived_logs/" % log_path
        if not os.path.exists(archived_folder):
            try:
                os.makedirs(archived_folder)
            except Exception:
                pass  # Should only be reachable during multi-threaded runs
        if not "".join(sys.argv) == "-c":
            # Only move log files if the test run is not multi-threaded.
            # (Running tests with "-n NUM" will create threads that only
            # have "-c" in the sys.argv list. Easy to catch.)
            archived_logs = "%slogs_%s" % (
                archived_folder, int(time.time()))
            shutil.move(log_path, archived_logs)
            os.makedirs(log_path)
            if not settings.ARCHIVE_EXISTING_LOGS and not archive_logs:
                shutil.rmtree(archived_logs)