Added Logger class; refactored logging accordingly

This commit is contained in:
Salvatore Ingala
2019-10-08 19:08:12 +07:00
parent 7f9c7d8609
commit bae9b6b913
11 changed files with 109 additions and 82 deletions

View File

@@ -1,4 +1,6 @@
from pisa import logging, M
from pisa import Logger
logger = Logger("Cleaner")
# Dictionaries in Python are "passed-by-reference", so no return is needed for the Cleaner"
# https://docs.python.org/3/faq/programming.html#how-do-i-write-a-function-with-output-parameters-call-by-reference
@@ -18,14 +20,13 @@ class Cleaner:
else:
locator_uuid_map[locator].remove(uuid)
logging.info(M("[Cleaner] end time reached with no match! Deleting appointment.",
locator=locator, uuid=uuid))
logger.info("end time reached with no match! Deleting appointment.", locator=locator, uuid=uuid)
@staticmethod
def delete_completed_jobs(jobs, tx_job_map, completed_jobs, height):
for uuid, confirmations in completed_jobs:
logging.info(M("[Cleaner] job completed. Appointment ended after reaching enough confirmations.",
uuid=uuid, height=height, confirmations=confirmations))
logger.info("job completed. Appointment ended after reaching enough confirmations.",
uuid=uuid, height=height, confirmations=confirmations)
# ToDo: #9-add-data-persistence
justice_txid = jobs[uuid].justice_txid
@@ -34,7 +35,7 @@ class Cleaner:
if len(tx_job_map[justice_txid]) == 1:
tx_job_map.pop(justice_txid)
logging.info(M("[Cleaner] no more jobs for justice transaction.", justice_txid=justice_txid))
logger.info("no more jobs for justice transaction.", justice_txid=justice_txid)
else:
tx_job_map[justice_txid].remove(uuid)