mirror of
https://github.com/GSA/notifications-api.git
synced 2026-07-28 11:49:42 -04:00
improve logging
This commit is contained in:
@@ -183,7 +183,7 @@ def insert_inbound_numbers_from_file(file_name):
|
||||
for line in file:
|
||||
line = line.strip()
|
||||
if line:
|
||||
current_app.logger.info(line)
|
||||
current_app.logger.debug(line)
|
||||
db.session.execute(sql, {"uuid": str(uuid.uuid4()), "line": line})
|
||||
db.session.commit()
|
||||
|
||||
@@ -228,7 +228,6 @@ def bulk_invite_user_to_service(file_name, service_id, user_id, auth_type, permi
|
||||
# "send_texts,send_emails,view_activity"
|
||||
from app.service_invite.rest import create_invited_user
|
||||
|
||||
current_app.logger.info("ENTER")
|
||||
file = open(file_name)
|
||||
for email_address in file:
|
||||
data = {
|
||||
@@ -239,7 +238,6 @@ def bulk_invite_user_to_service(file_name, service_id, user_id, auth_type, permi
|
||||
"auth_type": auth_type,
|
||||
"invite_link_host": current_app.config["ADMIN_BASE_URL"],
|
||||
}
|
||||
current_app.logger.info(f"DATA = {data}")
|
||||
with current_app.test_request_context(
|
||||
path=f"/service/{service_id}/invite/",
|
||||
method="POST",
|
||||
@@ -248,12 +246,12 @@ def bulk_invite_user_to_service(file_name, service_id, user_id, auth_type, permi
|
||||
):
|
||||
try:
|
||||
response = create_invited_user(service_id)
|
||||
current_app.logger.info(f"RESPONSE {response[1]}")
|
||||
current_app.logger.debug(f"RESPONSE {response[1]}")
|
||||
if response[1] != 201:
|
||||
current_app.logger.warning(
|
||||
f"*** ERROR occurred for email address: {email_address.strip()}"
|
||||
)
|
||||
current_app.logger.info(response[0].get_data(as_text=True))
|
||||
current_app.logger.debug(response[0].get_data(as_text=True))
|
||||
except Exception:
|
||||
current_app.logger.exception(
|
||||
f"*** ERROR occurred for email address: {email_address.strip()}.",
|
||||
@@ -337,7 +335,6 @@ def populate_organizations_from_file(file_name):
|
||||
|
||||
for line in itertools.islice(f, 1, None):
|
||||
columns = line.split("|")
|
||||
current_app.logger.info(columns)
|
||||
email_branding = None
|
||||
email_branding_column = columns[5].strip()
|
||||
if len(email_branding_column) > 0:
|
||||
@@ -439,20 +436,19 @@ def populate_go_live(file_name):
|
||||
# 6- Contact detail, 7-MOU, 8- LIVE date, 9- SMS, 10 - Email, 11 - Letters, 12 -CRM, 13 - Blue badge
|
||||
import csv
|
||||
|
||||
current_app.logger.info("Populate go live user and date")
|
||||
with open(file_name, "r") as f:
|
||||
rows = csv.reader(
|
||||
f,
|
||||
quoting=csv.QUOTE_MINIMAL,
|
||||
skipinitialspace=True,
|
||||
)
|
||||
current_app.logger.info(next(rows)) # ignore header row
|
||||
current_app.logger.debug(next(rows)) # ignore header row
|
||||
for index, row in enumerate(rows):
|
||||
current_app.logger.info(index, row)
|
||||
current_app.logger.debug(index, row)
|
||||
service_id = row[2]
|
||||
go_live_email = row[6]
|
||||
go_live_date = datetime.strptime(row[8], "%d/%m/%Y") + timedelta(hours=12)
|
||||
current_app.logger.info(service_id, go_live_email, go_live_date)
|
||||
current_app.logger.debug(service_id, go_live_email, go_live_date)
|
||||
try:
|
||||
if go_live_email:
|
||||
go_live_user = get_user_by_email(go_live_email)
|
||||
@@ -506,13 +502,11 @@ def fix_billable_units():
|
||||
)
|
||||
db.session.execute(stmt)
|
||||
db.session.commit()
|
||||
current_app.logger.info("End fix_billable_units")
|
||||
|
||||
|
||||
@notify_command(name="delete-unfinished-jobs")
|
||||
def delete_unfinished_jobs():
|
||||
cleanup_unfinished_jobs()
|
||||
current_app.logger.info("End cleanup_unfinished_jobs")
|
||||
|
||||
|
||||
@notify_command(name="process-row-from-job")
|
||||
@@ -618,7 +612,7 @@ def dump_user_info(user_email_address):
|
||||
with open("user_download.json", "wb") as f:
|
||||
f.write(json.dumps(content).encode("utf8"))
|
||||
f.close()
|
||||
current_app.logger.info("Successfully downloaded user info to user_download.json")
|
||||
current_app.logger.debug("Successfully downloaded user info to user_download.json")
|
||||
|
||||
|
||||
@notify_command(name="populate-annual-billing-with-defaults")
|
||||
|
||||
Reference in New Issue
Block a user