Added logging

This commit is contained in:
Dionysus 2023-11-03 11:55:37 -04:00
parent 0a3fce4c6c
commit 345824b91e
Signed by: acidvegas
GPG Key ID: EF4B922DB85DC9DE
1 changed files with 5 additions and 4 deletions

View File

@ -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}')
logging.error(f'An error occurred: {e}')