Add debug logging for deal filtering and --debug flag
Log the raw deal count before filtering and log each filtered-out deal with the reason (savings too low, rating too low) at DEBUG level. Use --debug flag to enable verbose output for troubleshooting. https://claude.ai/code/session_01LPpSZFfyh6vdV5HGFWjoQX
This commit is contained in:
@@ -13,17 +13,22 @@ from .config import Config
|
|||||||
from .preflight import run_preflight
|
from .preflight import run_preflight
|
||||||
|
|
||||||
|
|
||||||
def setup_logging():
|
def setup_logging(*, debug: bool = False):
|
||||||
logging.basicConfig(
|
logging.basicConfig(
|
||||||
level=logging.INFO,
|
level=logging.DEBUG if debug else logging.INFO,
|
||||||
format="%(asctime)s [%(levelname)s] %(name)s: %(message)s",
|
format="%(asctime)s [%(levelname)s] %(name)s: %(message)s",
|
||||||
stream=sys.stdout,
|
stream=sys.stdout,
|
||||||
)
|
)
|
||||||
|
if not debug:
|
||||||
|
# Keep noisy third-party loggers quiet even in debug mode
|
||||||
|
logging.getLogger("httpx").setLevel(logging.WARNING)
|
||||||
|
logging.getLogger("httpcore").setLevel(logging.WARNING)
|
||||||
|
|
||||||
|
|
||||||
async def main():
|
async def main():
|
||||||
load_dotenv()
|
load_dotenv()
|
||||||
setup_logging()
|
debug_mode = "--debug" in sys.argv
|
||||||
|
setup_logging(debug=debug_mode)
|
||||||
logger = logging.getLogger("gaming_deals_bot")
|
logger = logging.getLogger("gaming_deals_bot")
|
||||||
|
|
||||||
check_mode = "--check" in sys.argv
|
check_mode = "--check" in sys.argv
|
||||||
|
|||||||
@@ -68,14 +68,21 @@ async def fetch_deals(
|
|||||||
logger.error("CheapShark API error: %s", exc)
|
logger.error("CheapShark API error: %s", exc)
|
||||||
return []
|
return []
|
||||||
|
|
||||||
|
logger.info(
|
||||||
|
"CheapShark returned %d raw deals (before filtering)", len(raw_deals),
|
||||||
|
)
|
||||||
|
|
||||||
deals = []
|
deals = []
|
||||||
for d in raw_deals:
|
for d in raw_deals:
|
||||||
savings = float(d.get("savings", 0))
|
savings = float(d.get("savings", 0))
|
||||||
rating = float(d.get("dealRating", 0))
|
rating = float(d.get("dealRating", 0))
|
||||||
|
title = d.get("title", "?")
|
||||||
|
|
||||||
if savings < min_discount:
|
if savings < min_discount:
|
||||||
|
logger.debug("Filtered out %s: savings %.1f%% < %.1f%%", title, savings, min_discount)
|
||||||
continue
|
continue
|
||||||
if rating < min_rating:
|
if rating < min_rating:
|
||||||
|
logger.debug("Filtered out %s: rating %.1f < %.1f", title, rating, min_rating)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
steam_app_id = d.get("steamAppID") or None
|
steam_app_id = d.get("steamAppID") or None
|
||||||
|
|||||||
Reference in New Issue
Block a user