From e93c62a65f2d4d702f785e48355d1b4dc9781f84 Mon Sep 17 00:00:00 2001 From: Anes Belfodil Date: Mon, 9 Dec 2024 15:08:36 -0500 Subject: [PATCH] Adding log statements --- config.py | 1 + connection.py | 3 +++ wallpaper.py | 2 ++ 3 files changed, 6 insertions(+) diff --git a/config.py b/config.py index 29dbb6c..e495660 100644 --- a/config.py +++ b/config.py @@ -62,6 +62,7 @@ def _load_config(self): def _watch_config_changes(self): def watch_config(): + logger.info(f"Watch config changes") for changes in watch(self.config_file_path): self.raw_config = self._load_config() diff --git a/connection.py b/connection.py index 61a2d02..37438df 100644 --- a/connection.py +++ b/connection.py @@ -1,12 +1,15 @@ from urllib.request import urlopen, Request +from log import get_logger from time import sleep +logger = get_logger(__name__) def _is_connected(): try: urlopen(Request("https://1.1.1.1", headers={"User-Agent": "randwall/1.0"})) return True except: + logger.warning("Failed to connect to the internet.") return False diff --git a/wallpaper.py b/wallpaper.py index f9d91dd..4c2a6c8 100644 --- a/wallpaper.py +++ b/wallpaper.py @@ -86,6 +86,8 @@ def _get_random_wallpaper(): "ratios": "16x9,16x10", } + logger.info(f"Fetching random wallpaper from https://wallhaven.cc") + try: with urlopen(Request(api_url + urlencode(params), headers={"User-Agent": "randwall/1.0"})) as f: response = f.read().decode("utf-8")