From 475f9345ad40adbbb8e8b2a453cede253f86d2c0 Mon Sep 17 00:00:00 2001 From: Dreu LaVelle Date: Sun, 1 Sep 2024 11:26:49 -0500 Subject: [PATCH] fix: moved log cleaning to scheduled func. fixed bug with new furiosa movie --- poetry.lock | 6 +++--- src/program/program.py | 4 ++-- src/utils/cli.py | 4 ++-- src/utils/logger.py | 17 +---------------- 4 files changed, 8 insertions(+), 23 deletions(-) diff --git a/poetry.lock b/poetry.lock index 71a09c78..cce6a4d3 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1421,13 +1421,13 @@ files = [ [[package]] name = "parsett" -version = "1.2.3" +version = "1.2.4" description = "PTT" optional = false python-versions = "<4.0,>=3.11" files = [ - {file = "parsett-1.2.3-py3-none-any.whl", hash = "sha256:22cba9f02bcda2e89269012248f3e60831cf34c090be34bdc6eea5e0c4c3ed8a"}, - {file = "parsett-1.2.3.tar.gz", hash = "sha256:7ed3e00ca4f4e2a5f471efbfef21955872b31b7882164c17834c75ed3ec67e4b"}, + {file = "parsett-1.2.4-py3-none-any.whl", hash = "sha256:8dc96b19b410573fbfe0b533074b24a28cec5bb89488b412963e675004b63b62"}, + {file = "parsett-1.2.4.tar.gz", hash = "sha256:3a9b1c7b41fa66d9f05ed5f462f599c1122656659bb8ae32c82c28b2445f4395"}, ] [package.dependencies] diff --git a/src/program/program.py b/src/program/program.py index 0441d9d7..dae45a33 100644 --- a/src/program/program.py +++ b/src/program/program.py @@ -20,7 +20,7 @@ from program.settings.models import get_version from program.updaters import Updater from utils import data_dir_path -from utils.logger import logger, scrub_logs +from utils.logger import logger, log_cleaner from utils.event_manager import EventManager import utils.websockets.manager as ws_manager @@ -120,7 +120,6 @@ def start(self): settings_manager.save() self.initialize_services() - scrub_logs() max_worker_env_vars = [var for var in os.environ if var.endswith("_MAX_WORKERS")] if max_worker_env_vars: @@ -262,6 +261,7 @@ def _schedule_functions(self) -> None: """Schedule each service based on its update interval.""" scheduled_functions = { self._retry_library: {"interval": 60 * 10}, + log_cleaner: {"interval": 60 * 60}, vacuum_and_analyze_index_maintenance: {"interval": 60 * 60 * 24}, } diff --git a/src/utils/cli.py b/src/utils/cli.py index 7e6d534f..53a13db9 100644 --- a/src/utils/cli.py +++ b/src/utils/cli.py @@ -3,7 +3,7 @@ from program.db.db_functions import hard_reset_database from program.settings.manager import settings_manager from program.libraries.symlink import fix_broken_symlinks -from utils.logger import logger, scrub_logs +from utils.logger import logger, log_cleaner def handle_args(): @@ -42,7 +42,7 @@ def handle_args(): exit(0) if args.clean_logs: - scrub_logs() + log_cleaner() logger.info("Cleaned old logs.") exit(0) diff --git a/src/utils/logger.py b/src/utils/logger.py index 54ddafce..ecdc5150 100644 --- a/src/utils/logger.py +++ b/src/utils/logger.py @@ -73,21 +73,6 @@ def get_log_settings(name, default_color, default_icon): "{module}.{function} - {message}" ) - # handlers = { - # "sink": log_filename, - # "level": level, - # "format": log_format, - # "rotation": "50 MB", - # "retention": "8 hours", - # "compression": None, - # "backtrace": False, - # "diagnose": True, - # "enqueue": True, - # } - - # if LOG_ENABLED: - # handlers.append(log_filename) - logger.configure(handlers=[ { "sink": sys.stderr, @@ -122,7 +107,7 @@ def get_log_settings(name, default_color, default_icon): logger.add(WebSocketHandler(), format=log_format) -def scrub_logs(): +def log_cleaner(): """Remove old log files based on retention settings.""" try: logs_dir_path = data_dir_path / "logs"