#!/usr/bin/env python3
# vim: wrapmargin=0 textwidth=0 smarttab expandtab tabstop=2 shiftwidth=2
"""Produce a report on the provided EDDN Gateway log file's ERRORs."""
import argparse
import re
def parse_cl_args() -> str:
"""
Check command-line arguments for input file name.
:returns: str - input file name
"""
parser = argparse.ArgumentParser(
prog='eddn-report-log-errors',
description='Process an EDDN Gateway log file and report on any ERROR lines found'
)
parser.add_argument(
'inputfile',
metavar='',
help='Name of an EDDN Gateway log file'
)
args = parser.parse_args()
return args.inputfile
def process_file(input_file: str) -> None:
print(f'Input file: {input_file}')
_RE_ERROR = re.compile(
r'^[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}[\.,][0-9]{3} - ERROR - Gateway:[0-9]+:'
r' (?P.+)'
r' \((?P[0-9]+),'
r' "(?P[^"]*)",'
r' "(?P[^"]*)",'
r' "(?P[^"]*)",'
r' "(?P[^"]*)",'
r' "(?P[^"]*)"\)'
r' from (?P.+)$'
)
# TODO: Make this handle gzipped files
with open(input_file, 'r') as input:
line = input.readline()
while line:
line = line.strip()
matches = _RE_ERROR.search(line)
if matches:
# print(matches.group('err_msg'))
# print(matches.group('request_size'))
# print(matches.group('uploader_id'))
# print(matches.group('software_name'))
# print(matches.group('software_version'))
# print(matches.group('schema_ref'))
# print(matches.group('journal_event'))
# print(matches.group('sender_ip'))
# print('')
###################################################################
# Issues we know about and HAVE already alerted their
# developers to.
###################################################################
if matches.group('software_name') == 'EDDiscovery':
# https://github.com/EDDiscovery/EDDiscovery/releases/latest
if matches.group('software_version') == '12.1.7.0':
if matches.group('schema_ref') in (
'https://eddn.edcd.io/schemas/shipyard/2',
'https://eddn.edcd.io/schemas/outfitting/2',
):
# Reported via Discord PM to Robby 2022-01-07
if matches.group('err_msg') != 'Failed Validation "[]"':
print(line)
else:
print(line)
elif matches.group('software_name') == 'EDDLite':
# https://github.com/EDDiscovery/EDDLite/releases/tag/latest
if matches.group('software_version') == '2.0.0':
if matches.group('schema_ref') in (
'https://eddn.edcd.io/schemas/shipyard/2',
'https://eddn.edcd.io/schemas/outfitting/2',
):
# Reported via Discord PM to Robby 2022-01-07
if matches.group('err_msg') != 'Failed Validation "[]"':
print(line)
else:
print(line)
elif matches.group('software_name') == 'EDDI':
# https://github.com/EDCD/EDDI/releases/latest
if matches.group('software_version') == '4.0.1':
print(line)
elif matches.group('software_name') == 'E:D Market Connector [Windows]':
# https://github.com/EDCD/EDMarketConnector/releases/latest
if matches.group('software_version') == '5.2.4':
if matches.group('schema_ref') == 'https://eddn.edcd.io/schemas/codexentry/1':
#
if matches.group('err_msg') != 'Failed Validation "[]"':
print(matches.group('err_msg'))
print(line)
else:
print(line)
elif matches.group('software_name') == 'Elite G19s Companion App':
#
if matches.group('software_version') == '3.7.7888.21039':
if matches.group('schema_ref') == 'https://eddn.edcd.io/schemas/commodity/3':
# Reported via Frontier forums:
if matches.group('err_msg') != 'Failed Validation "[]"':
print(matches.group('err_msg'))
print(line)
else:
print(line)
elif matches.group('software_name') == 'EDSM':
# It's in-browser, no public source/releases
if matches.group('software_version') == '1.0.1':
if matches.group('schema_ref') == 'https://eddn.edcd.io/schemas/journal/1':
if matches.group('journal_event') == 'Scan':
#
if not matches.group('err_msg').startswith(
'Failed Validation "[
if not matches.group('err_msg').startswith(
'Failed Validation "[
if not matches.group('err_msg').startswith(
'Failed Validation "[