Improved logging and added option for --stdout.

This commit is contained in:
2025-07-22 21:14:11 +02:00
parent 2688a7df44
commit ab44bc0e96
5 changed files with 46 additions and 92 deletions

View File

@@ -2,13 +2,11 @@
import argparse
from . import database
from .logger_setup import get_logger
from .logger_setup import setup_logging, logger as log
# We can't reuse load_subreddits from main anymore if it's not in the same file
# So we will duplicate it here. It's small and keeps this script self-contained.
import json
log = get_logger()
def load_subreddits(filepath):
"""Loads a list of subreddits from a JSON file."""
try:
@@ -40,11 +38,16 @@ def run_cleanup():
)
parser.add_argument("--all", action="store_true", help="Run all available cleanup tasks.")
parser.add_argument("--stdout", action="store_true", help="Print all log messages to the console.")
args = parser.parse_args()
setup_logging(console_verbose=args.stdout)
run_any_task = False
log.critical("\n--- Starting Cleanup ---")
# --- UPDATED LOGIC TO HANDLE THE NEW ARGUMENT ---
if args.all or args.tickers:
run_any_task = True
@@ -65,7 +68,7 @@ def run_cleanup():
log.error("\nError: Please provide at least one cleanup option (e.g., --tickers, --subreddits, --all).")
return
log.info("\nCleanup finished.")
log.critical("\nCleanup finished.")
if __name__ == "__main__":
run_cleanup()