Log traceback to file in debug mode.

This commit is contained in:
tecnovert 2021-12-16 10:44:10 +02:00
parent 053c263751
commit 4a7eff0118
No known key found for this signature in database
GPG key ID: 8ED6D8750C4E3F93
3 changed files with 18 additions and 18 deletions

View file

@ -577,7 +577,7 @@ class BasicSwap(BaseApp):
time.sleep(4) # Extra time to settle
return
self.log.error('stopDaemon %s', str(ex))
traceback.print_exc()
self.log.error(traceback.format_exc())
raise ValueError('Could not stop {}'.format(str(coin)))
def stopDaemons(self):
@ -3383,7 +3383,7 @@ class BasicSwap(BaseApp):
except Exception as ex:
self.log.error('process_XMR_SWAP_A_LOCK_tx_spend %s', str(ex))
if self.debug:
traceback.print_exc()
self.log.error(traceback.format_exc())
finally:
session.close()
session.remove()
@ -3438,7 +3438,7 @@ class BasicSwap(BaseApp):
except Exception as ex:
self.log.error('process_XMR_SWAP_A_LOCK_REFUND_tx_spend %s', str(ex))
if self.debug:
traceback.print_exc()
self.log.error(traceback.format_exc())
finally:
session.close()
session.remove()
@ -3570,7 +3570,7 @@ class BasicSwap(BaseApp):
self.log.warning('Unknown event type: %d', row.event_type)
except Exception as ex:
if self.debug:
traceback.print_exc()
self.log.error(traceback.format_exc())
self.log.error('checkEvents failed: {}'.format(str(ex)))
if self.debug:
@ -4226,7 +4226,7 @@ class BasicSwap(BaseApp):
session.remove()
except Exception as ex:
if self.debug:
traceback.print_exc()
self.log.error(traceback.format_exc())
self.setBidError(bid.bid_id, bid, str(ex), xmr_swap=xmr_swap)
def watchXmrSwap(self, bid, offer, xmr_swap):
@ -4300,7 +4300,7 @@ class BasicSwap(BaseApp):
self.saveBidInSession(bid_id, bid, session, xmr_swap)
except Exception as ex:
if self.debug:
traceback.print_exc()
self.log.error(traceback.format_exc())
def sendXmrBidCoinALockTx(self, bid_id, session):
# Send coin A lock tx and MSG4F L -> F
@ -4685,7 +4685,7 @@ class BasicSwap(BaseApp):
self.saveBid(bid_id, bid, xmr_swap=xmr_swap)
except Exception as ex:
if self.debug:
traceback.print_exc()
self.log.error(traceback.format_exc())
self.setBidError(bid_id, bid, str(ex))
def processXmrBidLockSpendTx(self, msg):
@ -4725,7 +4725,7 @@ class BasicSwap(BaseApp):
self.saveBid(bid_id, bid, xmr_swap=xmr_swap)
except Exception as ex:
if self.debug:
traceback.print_exc()
self.log.error(traceback.format_exc())
self.setBidError(bid_id, bid, str(ex))
# Update copy of bid in swaps_in_progress
@ -4791,7 +4791,7 @@ class BasicSwap(BaseApp):
ensure(v, 'verifyTxOtVES failed for chain a lock tx leader esig')
except Exception as ex:
if self.debug:
traceback.print_exc()
self.log.error(traceback.format_exc())
self.setBidError(bid_id, bid, str(ex))
self.swaps_in_progress[bid_id] = (bid, offer)
return
@ -4834,7 +4834,7 @@ class BasicSwap(BaseApp):
except Exception as ex:
self.log.error('processMsg %s', str(ex))
if self.debug:
traceback.print_exc()
self.log.error(traceback.format_exc())
finally:
self.mxDB.release()
@ -4871,7 +4871,7 @@ class BasicSwap(BaseApp):
except Exception as ex:
self.log.error('smsg zmq %s', str(ex))
if self.debug:
traceback.print_exc()
self.log.error(traceback.format_exc())
self.mxDB.acquire()
try:
@ -4885,7 +4885,7 @@ class BasicSwap(BaseApp):
to_remove.append((bid_id, v[0], v[1]))
except Exception as ex:
if self.debug:
traceback.print_exc()
self.log.error('checkBidState %s', traceback.format_exc())
if self.is_transient_error(ex):
self.log.warning('checkBidState %s %s', bid_id.hex(), str(ex))
self.logBidEvent(bid_id, EventLogTypes.SYSTEM_WARNING, 'No connection to daemon', session=None)
@ -4920,7 +4920,7 @@ class BasicSwap(BaseApp):
except Exception as ex:
self.log.error('update %s', str(ex))
if self.debug:
traceback.print_exc()
self.log.error(traceback.format_exc())
finally:
self.mxDB.release()

View file

@ -827,7 +827,7 @@ class HttpHandler(BaseHTTPRequestHandler):
swap_client.setBidDebugInd(bytes.fromhex(sent_bid_id), debugind)
except Exception as ex:
if self.server.swap_client.debug is True:
traceback.print_exc()
self.server.swap_client.log.error(traceback.format_exc())
messages.append('Error: Send bid failed: ' + str(ex))
show_bid_form = True
@ -1297,7 +1297,7 @@ class HttpHandler(BaseHTTPRequestHandler):
return func(self, url_split, post_string, is_json)
except Exception as ex:
if self.server.swap_client.debug is True:
traceback.print_exc()
self.server.swap_client.log.error(traceback.format_exc())
return js_error(self, str(ex))
if len(url_split) > 1 and url_split[1] == 'static':
@ -1318,7 +1318,7 @@ class HttpHandler(BaseHTTPRequestHandler):
except Exception as ex:
self.putHeaders(status_code, 'text/html')
if self.server.swap_client.debug is True:
traceback.print_exc()
self.server.swap_client.log.error(traceback.format_exc())
return self.page_error(str(ex))
try:
@ -1361,7 +1361,7 @@ class HttpHandler(BaseHTTPRequestHandler):
return self.page_index(url_split)
except Exception as ex:
if self.server.swap_client.debug is True:
traceback.print_exc()
self.server.swap_client.log.error(traceback.format_exc())
return self.page_error(str(ex))
def do_GET(self):

View file

@ -204,7 +204,7 @@ def msg_thread(cls):
except Exception as e:
logging.warning('process message error %s', str(e))
if cls._sc.debug:
traceback.print_exc()
logging.error(traceback.format_exc())
if processed is False:
time.sleep(timeout)