mirror of
https://github.com/EDCD/EDMarketConnector.git
synced 2025-04-23 12:20:30 +03:00
plugins/inara: Convert to proper logging
This commit is contained in:
parent
4d7f81cec1
commit
7d060aa325
@ -15,12 +15,10 @@ import tkinter as tk
|
||||
from ttkHyperlinkLabel import HyperlinkLabel
|
||||
import myNotebook as nb
|
||||
|
||||
from EDMarketConnector import logger
|
||||
from config import appname, applongname, appversion, config
|
||||
import plug
|
||||
|
||||
if __debug__:
|
||||
from traceback import print_exc
|
||||
|
||||
|
||||
_TIMEOUT = 20
|
||||
FAKE = ['CQC', 'Training', 'Destination'] # Fake systems that shouldn't be sent to Inara
|
||||
@ -457,7 +455,7 @@ def journal_entry(cmdr, is_beta, system, station, entry, state):
|
||||
call()
|
||||
|
||||
except Exception as e:
|
||||
if __debug__: print_exc()
|
||||
logger.debug(f'Adding events', exc_info=e)
|
||||
return str(e)
|
||||
|
||||
#
|
||||
@ -898,14 +896,15 @@ def worker():
|
||||
callback(reply)
|
||||
elif status // 100 != 2: # 2xx == OK (maybe with warnings)
|
||||
# Log fatal errors
|
||||
print('Inara\t%s %s' % (reply['header']['eventStatus'], reply['header'].get('eventStatusText', '')))
|
||||
print(json.dumps(data, indent=2, separators = (',', ': ')))
|
||||
log.warning(f'Inara\t{status} {reply["header"].get("eventStatusText", "")}')
|
||||
log.debug(f'JSON data:\n{json.dumps(data, indent=2, separators = (",", ": "))}')
|
||||
plug.show_error(_('Error: Inara {MSG}').format(MSG = reply['header'].get('eventStatusText', status)))
|
||||
else:
|
||||
# Log individual errors and warnings
|
||||
for data_event, reply_event in zip(data['events'], reply['events']):
|
||||
if reply_event['eventStatus'] != 200:
|
||||
print('Inara\t%s %s\t%s' % (reply_event['eventStatus'], reply_event.get('eventStatusText', ''), json.dumps(data_event)))
|
||||
logger.warning(f'Inara\t{status} {reply_event.get("eventStatusText", "")}')
|
||||
logger.debug(f'JSON data:\n{json.dumps(data_event)}')
|
||||
if reply_event['eventStatus'] // 100 != 2:
|
||||
plug.show_error(_('Error: Inara {MSG}').format(MSG = '%s, %s' % (data_event['eventName'], reply_event.get('eventStatusText', reply_event['eventStatus']))))
|
||||
if data_event['eventName'] in ['addCommanderTravelCarrierJump', 'addCommanderTravelDock', 'addCommanderTravelFSDJump', 'setCommanderTravelLocation']:
|
||||
@ -916,8 +915,8 @@ def worker():
|
||||
this.system_link.event_generate('<<InaraShip>>', when="tail") # calls update_ship in main thread
|
||||
|
||||
break
|
||||
except:
|
||||
if __debug__: print_exc()
|
||||
except Exceptionas e:
|
||||
logger.debug(f'Sending events', exc_info=e)
|
||||
retrying += 1
|
||||
else:
|
||||
if callback:
|
||||
|
Loading…
x
Reference in New Issue
Block a user