|
6 | 6 | from utils.log import parse_log |
7 | 7 | import plotly.express as px |
8 | 8 |
|
9 | | -def analyse_log(log_info: dict) -> dict: |
| 9 | +def analyse_log(log_info: dict) -> list: |
10 | 10 | """ |
11 | 11 | Analyse the log information. |
12 | 12 |
|
13 | 13 | :param log_info |
14 | 14 | :return |
15 | 15 | """ |
16 | 16 | logs = [] |
| 17 | + current_message = None |
| 18 | + |
17 | 19 | for line in log_info: |
18 | 20 | match = re.search(r'(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2},\d{3}) - (\w+) - (\w+) - (.+)', line) |
19 | | - if not match: |
20 | | - continue |
21 | | - timestamp, logger_name, log_level, message = match.groups() |
22 | | - logs.append({ |
23 | | - 'timestamp': timestamp, |
24 | | - 'logger_name': logger_name, |
25 | | - 'log_level': log_level, |
26 | | - 'message': message |
27 | | - }) |
| 21 | + if match: |
| 22 | + if current_message: |
| 23 | + logs.append(current_message) |
| 24 | + |
| 25 | + timestamp, logger_name, log_level, message = match.groups() |
| 26 | + current_message = { |
| 27 | + 'timestamp': timestamp, |
| 28 | + 'logger_name': logger_name, |
| 29 | + 'log_level': log_level, |
| 30 | + 'message': message |
| 31 | + } |
| 32 | + elif current_message: |
| 33 | + current_message['message'] += '\n' + line.strip() |
| 34 | + |
| 35 | + if current_message: |
| 36 | + logs.append(current_message) |
28 | 37 |
|
29 | 38 | logs = [log_item for log_item in logs if log_item['log_level'] == 'INFO'] |
30 | 39 |
|
@@ -67,7 +76,6 @@ async def plot_rephrase_process(stats: list[dict]): |
67 | 76 | if __name__ == "__main__": |
68 | 77 | log = parse_log('/home/PJLAB/chenzihong/Project/graphgen/cache/logs/graphgen.log') |
69 | 78 | data = analyse_log(log) |
70 | | - |
71 | 79 | tokenizer = Tokenizer(model_name='cl100k_base') |
72 | 80 |
|
73 | 81 | for item in tqdm(data): |
|
0 commit comments