From 10aedc329fc91112f87e4444894dde96fa68dc1f Mon Sep 17 00:00:00 2001 From: oobabooga <112222186+oobabooga@users.noreply.github.com> Date: Thu, 22 Feb 2024 07:57:06 -0800 Subject: [PATCH] Logging: more readable messages when renaming chat histories --- modules/chat.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/modules/chat.py b/modules/chat.py index 7f25254c..237e8275 100644 --- a/modules/chat.py +++ b/modules/chat.py @@ -501,11 +501,11 @@ def rename_history(old_id, new_id, character, mode): old_p = get_history_file_path(old_id, character, mode) new_p = get_history_file_path(new_id, character, mode) if new_p.parent != old_p.parent: - logger.error(f"The following path is not allowed: {new_p}.") + logger.error(f"The following path is not allowed: \"{new_p}\".") elif new_p == old_p: logger.info("The provided path is identical to the old one.") else: - logger.info(f"Renaming {old_p} to {new_p}") + logger.info(f"Renaming \"{old_p}\" to \"{new_p}\"") old_p.rename(new_p) @@ -522,12 +522,13 @@ def find_all_histories(state): old_p = Path(f'logs/{character}_persistent.json') new_p = Path(f'logs/persistent_{character}.json') if old_p.exists(): - logger.warning(f"Renaming {old_p} to {new_p}") + logger.warning(f"Renaming \"{old_p}\" to \"{new_p}\"") old_p.rename(new_p) + if new_p.exists(): unique_id = datetime.now().strftime('%Y%m%d-%H-%M-%S') p = get_history_file_path(unique_id, character, state['mode']) - logger.warning(f"Moving {new_p} to {p}") + logger.warning(f"Moving \"{new_p}\" to \"{p}\"") p.parent.mkdir(exist_ok=True) new_p.rename(p)