Add action-group to re_dis_connect.

Used to not rely on position in message
for correct action-parsing.
This commit is contained in:
Thor77 2016-10-27 00:08:28 +02:00
parent c0523717a7
commit 2d80ba6804
1 changed files with 4 additions and 3 deletions

View File

@ -15,7 +15,7 @@ re_log_entry = re.compile('(?P<timestamp>\d{4}-\d\d-\d\d\ \d\d:\d\d:\d\d.\d+)'
'\|\ *(?P<level>\w+)\ *\|\ *(?P<component>\w+)\ *' '\|\ *(?P<level>\w+)\ *\|\ *(?P<component>\w+)\ *'
'\|\ *(?P<sid>\d+)\ *\|\ *(?P<message>.*)') '\|\ *(?P<sid>\d+)\ *\|\ *(?P<message>.*)')
re_dis_connect = re.compile( re_dis_connect = re.compile(
r"client (dis)?connected '(?P<nick>.*)'\(id:(?P<clid>\d+)\)") r"client (?P<action>(dis)?connected) '(?P<nick>.*)'\(id:(?P<clid>\d+)\)")
re_disconnect_invoker = re.compile( re_disconnect_invoker = re.compile(
r'invokername=(.*)\ invokeruid=(.*)\ reasonmsg' r'invokername=(.*)\ invokeruid=(.*)\ reasonmsg'
) )
@ -135,9 +135,10 @@ def _parse_details(log_path, ident_map=None, clients=None, online_dc=True):
nick, clid = match.group('nick'), match.group('clid') nick, clid = match.group('nick'), match.group('clid')
client = clients.setdefault(clid, Client(clid, nick)) client = clients.setdefault(clid, Client(clid, nick))
client.nick = nick # set nick to display changes client.nick = nick # set nick to display changes
if message.startswith('client connected'): action = match.group('action')
if action == 'connected':
client.connect(logdatetime) client.connect(logdatetime)
elif message.startswith('client disconnected'): elif action == 'disconnected':
client.disconnect(logdatetime) client.disconnect(logdatetime)
if 'invokeruid' in message: if 'invokeruid' in message:
re_disconnect_data = re_disconnect_invoker.findall( re_disconnect_data = re_disconnect_invoker.findall(