1
0
mirror of https://github.com/EDCD/EDMarketConnector.git synced 2025-04-17 17:42:20 +03:00

Extend logging to FSDJump as well for ease of testing.

FSDJump happens, relatively, seldom enough to not be too spammy.
This commit is contained in:
Athanasius 2020-09-18 15:33:18 +01:00
parent 3f001a383f
commit 0efe38540f

View File

@ -217,8 +217,8 @@ def credentials(cmdr):
def journal_entry(cmdr, is_beta, system, station, entry, state):
if entry['event'] == 'CarrierJump':
logger.debug(f'''CarrierJump
if entry['event'] in ('CarrierJump', 'FSDJump'):
logger.debug(f'''{entry["event"]}
Commander: {cmdr}
System: {system}
Station: {station}
@ -300,8 +300,8 @@ entry: {entry!r}'''
materials.update(transient)
this.queue.put((cmdr, materials))
if entry['event'] == 'CarrierJump':
logger.debug(f'''CarrierJump
if entry['event'] in ('CarrierJump', 'FSDJump'):
logger.debug(f'''{entry["event"]}
Queueing: {entry!r}'''
)
this.queue.put((cmdr, entry))
@ -359,12 +359,12 @@ def worker():
retrying = 0
while retrying < 3:
try:
if item and entry['event'] == 'CarrierJump':
logger.debug('CarrierJump')
if item and entry['event'] in ('CarrierJump', 'FSDJump'):
logger.debug(f'{entry["event"]}')
if item and entry['event'] not in this.discardedEvents:
if entry['event'] == 'CarrierJump':
logger.debug(f'CarrierJump event not in discarded list')
if entry['event'] in ('CarrierJump', 'FSDJump'):
logger.debug(f'{entry["event"]} event not in discarded list')
pending.append(entry)
# Get list of events to discard
@ -377,8 +377,8 @@ def worker():
pending = [x for x in pending if x['event'] not in this.discardedEvents] # Filter out unwanted events
if should_send(pending):
if any([p for p in pending if p['event'] == 'CarrierJump']):
logger.debug('CarrierJump in pending and it passed should_send()')
if any([p for p in pending if p['event'] in ('CarrierJump', 'FSDJump')]):
logger.debug('CarrierJump (or FSDJump) in pending and it passed should_send()')
(username, apikey) = credentials(cmdr)
data = {
@ -389,10 +389,10 @@ def worker():
'message': json.dumps(pending, ensure_ascii=False).encode('utf-8'),
}
if any([p for p in pending if p['event'] == 'CarrierJump']):
if any([p for p in pending if p['event'] in ('CarrierJump', 'FSDJump')]):
data_elided = data.copy()
data_elided['apiKey'] = '<elided>'
logger.debug(f'''CarrierJump: Attempting API call
logger.debug(f'''CarrierJump (or FSDJump): Attempting API call
data: {data_elided!r}'''
)
r = this.session.post('https://www.edsm.net/api-journal-v1', data=data, timeout=_TIMEOUT)