Commit babafcb3 authored by Arnaud WATLET's avatar Arnaud WATLET
Browse files

Adds log parser and exec_log plotting capability

Showing with 14 additions and 6 deletions
+14 -6
......@@ -4,10 +4,13 @@ from utils import parse_log
from datetime import datetime
import matplotlib
def plot_exec_log(exec_log,names=None):
time, process_id, tag, msg = parse_log(exec_log)
def plot_exec_log(exec_log,names=None,last_session=True):
time, process_id, tag, msg, session = parse_log(exec_log)
print(session)
if last_session:
time, process_id, tag, msg = time[session==max(session)], process_id[session==max(session)], tag[session==max(session)], msg[session==max(session)]
events = msg[tag == 'EVENT']
print(time)
category, name, state, time = np.empty(events.shape[0]).astype(str), np.empty(events.shape[0]).astype(str), \
np.empty(events.shape[0]).astype(str), np.empty(events.shape[0]).astype(str)
......
......@@ -64,8 +64,9 @@ def change_config(config_file, verbose=True):
def parse_log(log):
msg_started = False
msg_tmp = ''
s = 0
with open(log, "r") as file:
time, process_id, msg, tag = [], [], [], []
time, process_id, msg, tag, session = [], [], [], [], []
for i,line in enumerate(file):
if len(line.split(" | ")) > 1:
time.append(line.split(" | ")[0])
......@@ -80,9 +81,13 @@ def parse_log(log):
msg[-1] = msg[-1] + msg_tmp
msg_tmp = ''
msg_started = False
if tag[i] == 'INFO':
if 'NEW SESSION' in msg[i]:
s+=1
session.append(s)
time = np.array(time)
process_id = np.array(process_id)
tag = np.array(tag)
msg = np.array(msg)
return time, process_id, tag, msg
\ No newline at end of file
session = np.array(session)
return time, process_id, tag, msg, session
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment