Add logger function
import csv
import itertools
+import logging
from datetime import date
# The django-request analytics package, NOT the python URL library requests!
@@ -27,6 +28,8 @@ from .helpers import (
PYTHON,
)
+logger = logging.getLogger(__name__)
+
class DashboardView(TemplateView):
"""
@@ -254,6 +257,8 @@ class CSVProxyAuthRenewalRate(_CSVDownloadView):
for each_proxy_auth, each_renewed_auth in itertools.zip_longest(
proxy_auth_data, renewed_auth_data
):
+ # Checking if each_renewed_auth is a tuple, since that is what
+ # get_data_count_by_month should return
if len(each_renewed_auth) == 2:
each_proxy_auth.extend(
[
@@ -266,6 +271,8 @@ class CSVProxyAuthRenewalRate(_CSVDownloadView):
+ "%",
]
)
+ # If get_data_count_by_month does not return a tuple, print the
+ # returned value in the csv and log it
else:
each_proxy_auth.extend(
[
@@ -273,6 +280,9 @@ class CSVProxyAuthRenewalRate(_CSVDownloadView):
+ each_renewed_auth
]
)
+ logger.warning(
+ "Data is not a tuple. It instead returned: " + each_renewed_auth
+ )
writer = csv.writer(response)
writer.writerow(
