make logging not use f-str, change others to f-str (#22882)
This commit is contained in:
@@ -18,13 +18,13 @@ def recover_document_indexing_task(dataset_id: str, document_id: str):
|
||||
|
||||
Usage: recover_document_indexing_task.delay(dataset_id, document_id)
|
||||
"""
|
||||
logging.info(click.style("Recover document: {}".format(document_id), fg="green"))
|
||||
logging.info(click.style(f"Recover document: {document_id}", fg="green"))
|
||||
start_at = time.perf_counter()
|
||||
|
||||
document = db.session.query(Document).where(Document.id == document_id, Document.dataset_id == dataset_id).first()
|
||||
|
||||
if not document:
|
||||
logging.info(click.style("Document not found: {}".format(document_id), fg="red"))
|
||||
logging.info(click.style(f"Document not found: {document_id}", fg="red"))
|
||||
db.session.close()
|
||||
return
|
||||
|
||||
@@ -37,12 +37,10 @@ def recover_document_indexing_task(dataset_id: str, document_id: str):
|
||||
elif document.indexing_status == "indexing":
|
||||
indexing_runner.run_in_indexing_status(document)
|
||||
end_at = time.perf_counter()
|
||||
logging.info(
|
||||
click.style("Processed document: {} latency: {}".format(document.id, end_at - start_at), fg="green")
|
||||
)
|
||||
logging.info(click.style(f"Processed document: {document.id} latency: {end_at - start_at}", fg="green"))
|
||||
except DocumentIsPausedError as ex:
|
||||
logging.info(click.style(str(ex), fg="yellow"))
|
||||
except Exception:
|
||||
logging.exception("recover_document_indexing_task failed, document_id: {}".format(document_id))
|
||||
logging.exception("recover_document_indexing_task failed, document_id: %s", document_id)
|
||||
finally:
|
||||
db.session.close()
|
||||
|
Reference in New Issue
Block a user