From c18f0a2582d3f77042ed6162acb61f22a73e4ebc Mon Sep 17 00:00:00 2001 From: Luigi311 Date: Mon, 13 Jun 2022 18:16:55 -0600 Subject: [PATCH] Add debug_level option --- .env.sample | 2 ++ main.py | 6 +++--- src/functions.py | 5 ++++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/.env.sample b/.env.sample index c2e54fc..6464b80 100644 --- a/.env.sample +++ b/.env.sample @@ -2,6 +2,8 @@ DRYRUN = "True" ## Additional logging information DEBUG = "True" +## Debugging level, INFO is default, DEBUG is more verbose +DEBUG_LEVEL = "INFO" ## How often to run the script in seconds SLEEP_DURATION = "3600" ## Log file where all output will be written to diff --git a/main.py b/main.py index 4a54255..4b02093 100644 --- a/main.py +++ b/main.py @@ -46,7 +46,7 @@ def cleanup_watched(watched_list_1, watched_list_2, user_mapping=None, library_m for watch_list_2_item_key, watch_list_2_item_value in watch_list_2_item.items(): if watch_list_1_key == watch_list_2_item_key and watch_list_1_value == watch_list_2_item_value: if item in modified_watched_list_1[user_1][library_1]: - logger(f"Removing {item} from {library_1}", 1) + logger(f"Removing {item} from {library_1}", 3) modified_watched_list_1[user_1][library_1].remove(item) @@ -64,13 +64,13 @@ def cleanup_watched(watched_list_1, watched_list_2, user_mapping=None, library_m if episode_key in episode_watched_list_2_keys_dict.keys(): if episode_item in episode_watched_list_2_keys_dict[episode_key]: if episode in modified_watched_list_1[user_1][library_1][show_key_1][season]: - logger(f"Removing {show_key_dict['title']} {episode} from {library_1}", 1) + logger(f"Removing {show_key_dict['title']} {episode} from {library_1}", 3) modified_watched_list_1[user_1][library_1][show_key_1][season].remove(episode) # Remove empty seasons if len(modified_watched_list_1[user_1][library_1][show_key_1][season]) == 0: if season in modified_watched_list_1[user_1][library_1][show_key_1]: - logger(f"Removing {season} from {library_1} because it is empty", 1) + logger(f"Removing {season} from {library_1} because it is empty", 3) del modified_watched_list_1[user_1][library_1][show_key_1][season] # If the show is empty, remove the show diff --git a/src/functions.py b/src/functions.py index ae6a4bd..e246ead 100644 --- a/src/functions.py +++ b/src/functions.py @@ -6,14 +6,17 @@ logfile = os.getenv("LOGFILE","log.log") def logger(message, log_type=0): debug = str_to_bool(os.getenv("DEBUG", "True")) + debug_level = os.getenv("DEBUG_LEVEL", "INFO") output = str(message) if log_type == 0: pass - elif log_type == 1 and debug: + elif log_type == 1 and (debug or debug_level == "INFO"): output = f"[INFO]: {output}" elif log_type == 2: output = f"[ERROR]: {output}" + elif log_type == 3 and (debug and debug_level == "DEBUG"): + output = f"[DEBUG]: {output}" else: output = None