Skip to content

Commit

Permalink
Adding log statements
Browse files Browse the repository at this point in the history
  • Loading branch information
abelfodil committed Dec 9, 2024
1 parent daaedaf commit e93c62a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
3 changes: 3 additions & 0 deletions connection.py
Original file line number Diff line number Diff line change
@@ -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


Expand Down
2 changes: 2 additions & 0 deletions wallpaper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit e93c62a

Please sign in to comment.