mirror of
https://github.com/User0332/rewards-farmer.git
synced 2026-09-16 01:31:36 +00:00
switch the bot runtime from print to logging
Closes #14. The runtime modules now log through the stdlib logging module. A new log_utils.setup_logging is called once from main.py, and each module holds its own logging.getLogger(__name__) so every line says which module it came from. The [INFO] and [WARNING] prefixes are gone, since the level field carries that now. [OK], [SKIP] and [FAIL] stay in the message text: they are the per-task outcome summary from complete_all_tasks rather than severities, and folding them into the level would erase the run summary. They map to info, warning and error, which is the one thing print could not express, a real failure now sorts above a task the current UI variant simply does not ship. Two things fall out of having levels at all: - REWARDS_FARMER_LOG_LEVEL=DEBUG attaches the traceback to every [FAIL], which is the stack trace that bug reports keep having to be asked for. - REWARDS_FARMER_LOG_FILE writes the same output to a file, so an unattended run can be read after the fact. Both are off by default, so a normal run looks the same as before apart from the timestamp and level columns. The [FAIL] summary keeps only the first line of the exception message. A selenium exception carries the whole msedgedriver stacktrace inside str(), tens of lines of it, which would turn one task into one screenful and make the log file impossible to scan. The full detail is still there with the traceback on debug. The console stream is stdout rather than the StreamHandler default of stderr, so anyone already redirecting stdout keeps getting the output there, and its error handler is set to replace. Card descriptions are scraped from the page and are not ASCII outside the en-US market, and the Windows console encoding raises on them. check_selectors.py, fitts_law.py and analyze_keypresses.py are left on print. Their output is formatted report text, and prefixing every row of a diagnostic table with a timestamp and a level makes it harder to read.
This commit is contained in:
@@ -1,9 +1,12 @@
|
||||
import log_utils
|
||||
import rewards_tasks
|
||||
import mouse_trajectory
|
||||
import mimic_typing
|
||||
from selenium import webdriver
|
||||
from constants import USER_DATA_DIR, PROFILE_NAME
|
||||
|
||||
log_utils.setup_logging()
|
||||
|
||||
options = webdriver.EdgeOptions()
|
||||
|
||||
options.add_experimental_option("excludeSwitches", ["enable-automation"])
|
||||
|
||||
Reference in New Issue
Block a user