From 345824b91ed591ee35d495b78a911385f16a1539 Mon Sep 17 00:00:00 2001 From: acidvegas Date: Fri, 3 Nov 2023 11:55:37 -0400 Subject: [PATCH] Added logging --- czdz.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/czdz.py b/czdz.py index 12631c7..0150f6b 100644 --- a/czdz.py +++ b/czdz.py @@ -10,6 +10,7 @@ References: import argparse import concurrent.futures import getpass +import logging import os try: @@ -72,9 +73,9 @@ def main(username: str, password: str, concurrency: int): url = future_to_url[future] try: filepath = future.result() - print(f'Completed downloading {url} to file {filepath}') + logging.info(f'Completed downloading {url} to file {filepath}') except Exception as e: - print(f'{url} generated an exception: {e}') + logging.error(f'{url} generated an exception: {e}') @@ -96,6 +97,6 @@ if __name__ == '__main__': try: main(username, password, args.concurrency) except requests.HTTPError as e: - print(f'HTTP error occurred: {e.response.status_code} - {e.response.reason}') + logging.error(f'HTTP error occurred: {e.response.status_code} - {e.response.reason}') except Exception as e: - print(f'An error occurred: {e}') \ No newline at end of file + logging.error(f'An error occurred: {e}') \ No newline at end of file