Commit 2ce0bf47 authored by Navin Karkera's avatar Navin Karkera
Browse files

refactor: add logging handler

parent ad5992b5
Pipeline #587998994 passed with stage
in 1 minute and 42 seconds
......@@ -2,7 +2,9 @@
Config settings from environment
"""
import logging
import os
import sys
from datetime import datetime
from pathlib import Path
from typing import List, Optional
......@@ -118,5 +120,12 @@ class TestSettings(ProdSettings): # pylint: disable=too-few-public-methods
debug: bool = Field(True, env="DEBUG")
# logging config
LOG_FORMAT = "%(levelname)s %(name)s %(asctime)s - %(message)s"
logging.basicConfig(
stream=sys.stdout, filemode="w", format=LOG_FORMAT, level=logging.INFO
)
# app config
config_map = {"prod": ProdSettings, "test": TestSettings}
settings = config_map.get(os.getenv("ENV", "prod"), ProdSettings)()
......@@ -132,6 +132,7 @@ def download_recording(
try:
# Get URL and download the file.
token = conn.config.get("token")
logger.info("starting download for meeting: %s", recording_details["topic"])
download_response = requests.get(
recording_details["download_url"],
stream=True,
......@@ -142,8 +143,8 @@ def download_recording(
) # Copy raw file data to local file.
logger.info(
"recording downloaded for meeting %s to %s.",
recording_details["meeting_id"],
"recording downloaded for meeting: %s to %s.",
recording_details["topic"],
file_obj.name,
)
return {"success": True, "date": recording_details["recording_start"]}
......@@ -169,6 +170,7 @@ def delete_recording(
meeting_name (str): meeting name or topic to identify in logs
action (str): default to trash, which moves recording to trash in cloud
"""
logger.info("moving zoom recording for meeting: %s to trash", meeting_name)
response = conn.recording.delete_single_recording(
meeting_id=meeting_id, recording_id=recording_id, action=action
)
......
......@@ -120,8 +120,10 @@ def upload_meeting(
)
# create folder if not found
if not meeting_folder:
logger.info("%s folder not found in drive, creating...", drive_folder)
meeting_folder = create_folder(conn, drive_folder, drive_base_dir_id)
# upload recording to the meeting_folder
logger.info("uploading recording: %s", file_name)
file_url = upload_to_drive(conn, file_path, file_name, meeting_folder)
return file_url
......@@ -148,6 +150,7 @@ def send_notification(
plain_template = jinja_env.get_template("email/migration_notification.txt")
plain_content = plain_template.render(data=data)
logger.info("Sending email notification with body:\n %s", plain_content)
with connect_to_smtp(email_settings) as conn:
send_mail(
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment