Skip to content

Commit

Permalink
Merge pull request #34 from madeddie/fix_logging
Browse files Browse the repository at this point in the history
Use the created logger and not the root logger
  • Loading branch information
madeddie authored May 14, 2024
2 parents 63f2c3d + a6f6c18 commit c532e7c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ __pycache__
*.json
cookies.txt
.coverage
.envrc
8 changes: 4 additions & 4 deletions moocfi_cses.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def login(self) -> None:
if login_link:
login_url = urljoin(res.url, login_link.get("href"))
else:
logging.debug(
logger.debug(
f"url: {res.url}, status: {res.status_code}\nhtml:\n{res.text}"
)
raise ValueError("Failed to find login url")
Expand All @@ -64,7 +64,7 @@ def login(self) -> None:
action = login_form.get("_action")
login_form.pop("_action")
else:
logging.debug(
logger.debug(
f"url: {res.url}, status: {res.status_code}\nhtml:\n{res.text}"
)
raise ValueError("Failed to find login form")
Expand All @@ -79,7 +79,7 @@ def login(self) -> None:
)

if not self.is_logged_in:
logging.debug(
logger.debug(
f"url: {res.url}, status: {res.status_code}\nhtml:\n{res.text}"
)
raise ValueError("Login failed")
Expand Down Expand Up @@ -194,7 +194,7 @@ def read_cookie_file(cookiefile: str) -> dict[str, str]:
with open(cookiefile, "r") as f:
return json.load(f)
except (FileNotFoundError, json.decoder.JSONDecodeError) as e:
logging.debug(f"Error reading cookies from {cookiefile}: {e}")
logger.debug(f"Error reading cookies from {cookiefile}: {e}")
return {}


Expand Down

0 comments on commit c532e7c

Please sign in to comment.