From a6f35b294e9a899b90c4b2d32233da2d9a8ae9e8 Mon Sep 17 00:00:00 2001 From: Kim Huebel Date: Fri, 20 Nov 2020 18:39:32 +0000 Subject: [PATCH] Enabled target lookup with DMRIds.dat --- logtailer.py | 41 +++++++++++++++++++++++++++++++++-------- 1 file changed, 33 insertions(+), 8 deletions(-) diff --git a/logtailer.py b/logtailer.py index c069462..cffef34 100644 --- a/logtailer.py +++ b/logtailer.py @@ -67,10 +67,22 @@ def view_log(websocket, path): content = conv.convert(content, full=False) lines = content.split("\n") for line in lines: - if line.find("from ") > 0 and line.find("to ") > 0: - source = line[line.index("from ") + 5:line.index("to ")].strip() - if source in dmrids: - line = line.replace(source, dmrids[source]) + if line.find("received") > 0 or line.find("network watchdog") > 0: + if line.find("from ") > 0 and line.find("to ") > 0: + source = line[line.index("from ") + 5:line.index("to ")].strip() + if source in dmrids: + line = line.replace(source, dmrids[source]) + if line.find("to ") > 0: + if line.find("at ") > 0 and line.find("late entry") < 0: + target = line[line.index("to ") + 3:line.rindex("at ")] + if target in dmrids: + line = line.replace(target, dmrids[target]) + else: + target = line[line.index("to") + 3:] + if target.find(",") > 0: + target = target[0:target.index(",")] + if target in dmrids: + line = line.replace(target, dmrids[target]) yield from websocket.send(line) while True: @@ -79,10 +91,22 @@ def view_log(websocket, path): content = conv.convert(content, full=False) lines = content.split("\n") for line in lines: - if line.find("from ") > 0 and line.find("to ") > 0: - source = line[line.index("from ") + 5:line.index("to ")].strip() - if source in dmrids: - line = line.replace(source, dmrids[source]) + if line.find("received") > 0 or line.find("network watchdog") > 0: + if line.find("from ") > 0 and line.find("to ") > 0: + source = line[line.index("from ") + 5:line.index("to ")].strip() + if source in dmrids: + line = line.replace(source, dmrids[source]) + if line.find("to ") > 0: + if line.find("at ") > 0 and line.find("late entry") < 0: + target = line[line.index("to ") + 3:line.rindex("at ")] + if target in dmrids: + line = line.replace(target, dmrids[target]) + else: + target = line[line.index("to") + 3:] + if target.find(",") > 0: + target = target[0:target.index(",")] + if target in dmrids: + line = line.replace(target, dmrids[target]) yield from websocket.send(line) else: yield from asyncio.sleep(0.2) @@ -153,6 +177,7 @@ def main(): for line in lines: tokens = line.split("\t") dmrids[tokens[0]] = tokens[1] + logging.info("Starting Websocketserver") websocketserver()