Replace logging with app.logger.

This commit is contained in:
Cristiano Ferreira
2023-12-12 23:02:00 +00:00
parent 2b91cfe26d
commit 479620116d
3 changed files with 27 additions and 24 deletions

18
app.py
View File

@@ -58,7 +58,7 @@ def get_listening_section_1_question():
unprocessed_conversation, processed_conversation = generate_listening_1_conversation(topic)
logging.info("Generated conversation: " + str(processed_conversation))
app.logger.info("Generated conversation: " + str(processed_conversation))
start_id = 1
exercises = generate_listening_conversation_exercises(unprocessed_conversation, req_exercises,
@@ -88,7 +88,7 @@ def get_listening_section_2_question():
monologue = generate_listening_2_monologue(topic)
logging.info("Generated monologue: " + str(monologue))
app.logger.info("Generated monologue: " + str(monologue))
start_id = 11
exercises = generate_listening_monologue_exercises(monologue, req_exercises, number_of_exercises_q, start_id)
return {
@@ -115,7 +115,7 @@ def get_listening_section_3_question():
unprocessed_conversation, processed_conversation = generate_listening_3_conversation(topic)
logging.info("Generated conversation: " + str(processed_conversation))
app.logger.info("Generated conversation: " + str(processed_conversation))
start_id = 21
exercises = generate_listening_conversation_exercises(unprocessed_conversation, req_exercises,
@@ -145,7 +145,7 @@ def get_listening_section_4_question():
monologue = generate_listening_4_monologue(topic)
logging.info("Generated monologue: " + str(monologue))
app.logger.info("Generated monologue: " + str(monologue))
start_id = 31
exercises = generate_listening_monologue_exercises(monologue, req_exercises, number_of_exercises_q, start_id)
return {
@@ -532,7 +532,7 @@ def save_speaking():
exercises = data.get('exercises')
template = getSpeakingTemplate()
id = str(uuid.uuid4())
logging.info('Received request to save speaking with id: ' + id)
app.logger.info('Received request to save speaking with id: ' + id)
thread_event.set()
thread = threading.Thread(
target=create_videos_and_save_to_db,
@@ -540,7 +540,7 @@ def save_speaking():
name=("thread-save-speaking-" + id)
)
thread.start()
logging.info('Started thread to save speaking. Thread: ' + thread.getName())
app.logger.info('Started thread to save speaking. Thread: ' + thread.getName())
# Return response without waiting for create_videos_and_save_to_db to finish
return {**template, "id": id}
@@ -562,7 +562,7 @@ def get_reading_passage_1_question():
number_of_exercises_q = divide_number_into_parts(TOTAL_READING_PASSAGE_1_EXERCISES, len(req_exercises))
passage = generate_reading_passage(QuestionType.READING_PASSAGE_1, topic)
logging.info("Generated passage: " + str(passage))
app.logger.info("Generated passage: " + str(passage))
start_id = 1
exercises = generate_reading_exercises(passage["text"], req_exercises, number_of_exercises_q, start_id)
return {
@@ -590,7 +590,7 @@ def get_reading_passage_2_question():
number_of_exercises_q = divide_number_into_parts(TOTAL_READING_PASSAGE_2_EXERCISES, len(req_exercises))
passage = generate_reading_passage(QuestionType.READING_PASSAGE_2, topic)
logging.info("Generated passage: " + str(passage))
app.logger.info("Generated passage: " + str(passage))
start_id = 14
exercises = generate_reading_exercises(passage["text"], req_exercises, number_of_exercises_q, start_id)
return {
@@ -618,7 +618,7 @@ def get_reading_passage_3_question():
number_of_exercises_q = divide_number_into_parts(TOTAL_READING_PASSAGE_3_EXERCISES, len(req_exercises))
passage = generate_reading_passage(QuestionType.READING_PASSAGE_3, topic)
logging.info("Generated passage: " + str(passage))
app.logger.info("Generated passage: " + str(passage))
start_id = 27
exercises = generate_reading_exercises(passage["text"], req_exercises, number_of_exercises_q, start_id)
return {