better logging
This commit is contained in:
parent
fdd3a66644
commit
d71927ddc4
@ -67,6 +67,7 @@ os.makedirs(log_dir, exist_ok=True)
|
|||||||
error_file_handler = RotatingFileHandler( log_file, maxBytes=10*1024*1024, backupCount=5)
|
error_file_handler = RotatingFileHandler( log_file, maxBytes=10*1024*1024, backupCount=5)
|
||||||
error_file_handler.setLevel(logging.ERROR)
|
error_file_handler.setLevel(logging.ERROR)
|
||||||
error_file_handler.setFormatter(logging.Formatter('%(asctime)s [%(levelname)s] %(message)s', datefmt='%Y-%m-%d %H:%M:%S') )
|
error_file_handler.setFormatter(logging.Formatter('%(asctime)s [%(levelname)s] %(message)s', datefmt='%Y-%m-%d %H:%M:%S') )
|
||||||
|
error_file_handler.formatter.converter = time.localtime
|
||||||
error_logger = logging.getLogger('error_logger')
|
error_logger = logging.getLogger('error_logger')
|
||||||
error_logger.setLevel(logging.ERROR)
|
error_logger.setLevel(logging.ERROR)
|
||||||
error_logger.addHandler(error_file_handler)
|
error_logger.addHandler(error_file_handler)
|
||||||
@ -945,19 +946,20 @@ async def save_token_info():
|
|||||||
with open('./logs/token_info.json', 'w') as f:
|
with open('./logs/token_info.json', 'w') as f:
|
||||||
json.dump(TOKENS_INFO, f, indent=2)
|
json.dump(TOKENS_INFO, f, indent=2)
|
||||||
|
|
||||||
async def get_transaction_details_with_retry(transaction_id, retry_delay = 8, max_retries = 16):
|
async def get_transaction_details_with_retry(transaction_id, retry_delay = 5, max_retries = 16):
|
||||||
# wait for the transaction to be confirmed
|
# wait for the transaction to be confirmed
|
||||||
# await async_client.wait_for_confirmation(Signature.from_string(transaction_id))
|
# await async_client.wait_for_confirmation(Signature.from_string(transaction_id))
|
||||||
# qwery every 5 seconds for the transaction details untill not None or 30 seconds
|
# query every 5 seconds for the transaction details until not None or 30 seconds
|
||||||
for _ in range(max_retries):
|
for _ in range(max_retries):
|
||||||
try:
|
try:
|
||||||
tx_details = await get_transaction_details_rpc(transaction_id)
|
tx_details = await get_transaction_details_rpc(transaction_id)
|
||||||
if tx_details is not None:
|
if tx_details is not None:
|
||||||
break
|
break
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.error(f"Error fetching transaction details: {e}")
|
logging.error(f"Error fetching transaction details for '{transaction_id}': {e}")
|
||||||
logging.info(f"({_} of {max_retries}) Waiting for transaction details for {transaction_id}")
|
logging.info(f"({_} of {max_retries}) Waiting for transaction details for {transaction_id}")
|
||||||
await asyncio.sleep(retry_delay)
|
await asyncio.sleep(retry_delay)
|
||||||
|
retry_delay *= 1.2
|
||||||
return tx_details
|
return tx_details
|
||||||
|
|
||||||
|
|
||||||
@ -1084,6 +1086,7 @@ async def process_log(log_result):
|
|||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.error(f"Error aquiring log details and following: {e}")
|
logging.error(f"Error aquiring log details and following: {e}")
|
||||||
|
error_logger.info(f"Error aquiring log details and following:\n {tr_details}")
|
||||||
await send_telegram_message(f"Not followed! Error following move.")
|
await send_telegram_message(f"Not followed! Error following move.")
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user