Development

This commit is contained in:
Matthew Grotke 2026-06-09 12:21:06 -04:00
parent a2c2d05d58
commit 8c98b95868

View file

@ -43,7 +43,9 @@ def load_config():
return json.load(f)
def setup_logging():
def setup_logging(data):
general = data.get("dns_blocking", {}).get("general", {})
errors_only = general.get("log_errors_only", False)
BLOCKLIST_DIR.mkdir(exist_ok=True)
try:
file_handler = logging.FileHandler(LOG_FILE, mode='a')
@ -54,7 +56,7 @@ def setup_logging():
if file_handler:
handlers.insert(0, file_handler)
logging.basicConfig(
level=logging.INFO,
level=logging.ERROR if errors_only else logging.INFO,
format="%(asctime)s %(levelname)-8s %(message)s",
datefmt="%Y-%m-%d %H:%M:%S",
handlers=handlers,
@ -87,8 +89,8 @@ def download_blocklists(data):
def main():
check_root()
setup_logging()
data = load_config()
setup_logging(data)
LAST_DL_FILE.write_text(str(int(__import__('time').time())))
logging.info("Downloading blocklists ==========================================")
success = download_blocklists(data)