def log_folder_setup(log_path, archive_logs=False):
if log_path.endswith("<STR_LIT:/>"):<EOL><INDENT>log_path = log_path[:-<NUM_LIT:1>]<EOL><DEDENT>if not os.path.exists(log_path):<EOL><INDENT>try:<EOL><INDENT>os.makedirs(log_path)<EOL><DEDENT>except Exception:<EOL><INDENT>pass  <EOL><DEDENT><DEDENT>else:<EOL><INDENT>archived_folder = "<STR_LIT>" % log_path<EOL>if not os.path.exists(archived_folder):<EOL><INDENT>try:<EOL><INDENT>os.makedirs(archived_folder)<EOL><DEDENT>except Exception:<EOL><INDENT>pass  <EOL><DEDENT><DEDENT>if not "<STR_LIT>".join(sys.argv) == "<STR_LIT:-c>":<EOL><INDENT>archived_logs = "<STR_LIT>" % (<EOL>archived_folder, int(time.time()))<EOL>shutil.move(log_path, archived_logs)<EOL>os.makedirs(log_path)<EOL>if not settings.ARCHIVE_EXISTING_LOGS and not archive_logs:<EOL><INDENT>shutil.rmtree(archived_logs)<EOL><DEDENT><DEDENT><DEDENT>
Handle Logging