1
0
mirror of https://github.com/EDCD/EDMarketConnector.git synced 2025-06-06 10:23:06 +03:00

plugins/edsm: Converted to proper logging

This commit is contained in:
Athanasius 2020-07-24 21:17:59 +01:00
parent 6aa409388e
commit 7951463fba

View File

@ -23,11 +23,10 @@ import tkinter as tk
from ttkHyperlinkLabel import HyperlinkLabel from ttkHyperlinkLabel import HyperlinkLabel
import myNotebook as nb import myNotebook as nb
from EDMarketConnector import logger
from config import appname, applongname, appversion, config from config import appname, applongname, appversion, config
import plug import plug
if __debug__:
from traceback import print_exc
EDSM_POLL = 0.1 EDSM_POLL = 0.1
_TIMEOUT = 20 _TIMEOUT = 20
@ -359,7 +358,7 @@ def worker():
(msgnum, msg) = reply['msgnum'], reply['msg'] (msgnum, msg) = reply['msgnum'], reply['msg']
# 1xx = OK, 2xx = fatal error, 3&4xx not generated at top-level, 5xx = error but events saved for later processing # 1xx = OK, 2xx = fatal error, 3&4xx not generated at top-level, 5xx = error but events saved for later processing
if msgnum // 100 == 2: if msgnum // 100 == 2:
print('EDSM\t%s %s\t%s' % (msgnum, msg, json.dumps(pending, separators = (',', ': ')))) logger.warning(f'EDSM\t{msgnum} {msg}\t{json.dumps(pending, separators = (",", ": "))}')
plug.show_error(_('Error: EDSM {MSG}').format(MSG=msg)) plug.show_error(_('Error: EDSM {MSG}').format(MSG=msg))
else: else:
for e, r in zip(pending, reply['events']): for e, r in zip(pending, reply['events']):
@ -368,12 +367,12 @@ def worker():
this.lastlookup = r this.lastlookup = r
this.system_link.event_generate('<<EDSMStatus>>', when="tail") # calls update_status in main thread this.system_link.event_generate('<<EDSMStatus>>', when="tail") # calls update_status in main thread
elif r['msgnum'] // 100 != 1: elif r['msgnum'] // 100 != 1:
print('EDSM\t%s %s\t%s' % (r['msgnum'], r['msg'], json.dumps(e, separators = (',', ': ')))) logger.warning(f'EDSM\t{r["msgnum"]} {r["msg"]}\t{json.dumps(e, separators = (",", ": "))}')
pending = [] pending = []
break break
except: except Exception as e:
if __debug__: print_exc() logger.debug(f'Sending API events', exc_info=e)
retrying += 1 retrying += 1
else: else:
plug.show_error(_("Error: Can't connect to EDSM")) plug.show_error(_("Error: Can't connect to EDSM"))