From 121a79245da6ce50fab2c50f7ae4704575417c67 Mon Sep 17 00:00:00 2001 From: Dobromir Popov Date: Wed, 9 Oct 2024 09:43:52 +0300 Subject: [PATCH] ensure log file exists --- crypto/sol/app.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/crypto/sol/app.py b/crypto/sol/app.py index 82e285c..e78890d 100644 --- a/crypto/sol/app.py +++ b/crypto/sol/app.py @@ -47,11 +47,10 @@ logger = logging.getLogger(__name__) logging.basicConfig(level=logging.DEBUG) # Set up error logger -error_file_handler = RotatingFileHandler( - './logs/error.log', - maxBytes=10*1024*1024, # 10MB - backupCount=5 -) +log_dir = './logs' +log_file = os.path.join(log_dir, 'error.log') +os.makedirs(log_dir, exist_ok=True) +error_file_handler = RotatingFileHandler( log_file, maxBytes=10*1024*1024, backupCount=5) 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_logger = logging.getLogger('error_logger') @@ -1025,7 +1024,7 @@ async def follow_move(move): signature = private_key.sign_message(message.to_bytes_versioned(raw_transaction.message)) signed_txn = VersionedTransaction.populate(raw_transaction.message, [signature]) opts = TxOpts(skip_preflight=False, preflight_commitment=Processed) - + # send the transaction result = await async_client.send_raw_transaction(txn=bytes(signed_txn), opts=opts)