22import re
33
44patterns = [
5- # 2021E
6- (
7- br'^'
5+ re . compile ( b'' . join ([
6+ # 2021E
7+ br'^' ,
88
99 # Current timestamp.
10- br'(?P<timestamp>[\d\.]+),'
10+ br'(?P<timestamp>[\d\.]+),' ,
1111
1212 # Changes randomly between RCC sessions.
13- br'[0-9a-f]+,'
13+ br'[0-9a-f]+,' ,
1414
1515 # RCC's own log level.
16- br'(?P<rcc_log_num>\d+),'
16+ br'(?P<rcc_log_num>\d+),' ,
1717
1818 # Constant across all RCC logs.
19- br'GameServer,'
19+ br'GameServer,' ,
2020
2121 # Defaults to 1818.
22- br'[^\s,]+,'
22+ br'[^\s,]+,' ,
2323
2424 # Defaults to 13058.
25- br'[^\s,]+,'
25+ br'[^\s,]+,' ,
2626
2727 # Defaults to "https://localhost:2005/.127.0.0.1".
28- br'[^\s,]+,'
28+ br'[^\s,]+,' ,
2929
3030 # Constant across all RCC logs.
31- br'Test,'
31+ br'Test,' ,
3232
3333 # Defaults to "https://localhost:2005".
34- br'[^\s,]+,'
34+ br'[^\s,]+,' ,
3535
3636 # Constant across all RCC logs.
37- br'unknown,'
37+ br'unknown,' ,
3838
3939 # Constant across all RCC logs.
40- br'Test'
40+ br'Test' ,
4141
4242 # Gets FLog type.
43- br' \[(?P<log_name>.*?)\]'
43+ br' \[(?P<log_name>.*?)\]' ,
4444
4545 # Captures the rest of the line.
46- br' (?P<rest_of_line>.+)$'
47- ),
48-
49- # 2021E
50- (
51- br'^'
46+ br' (?P<rest_of_line>.+)$' ,
47+ ])),
48+ re .compile (b'' .join ([
49+ # 2021E
50+ br'^' ,
5251
5352 # Current timestamp.
54- br'(?P<timestamp>[\d\.]+),'
53+ br'(?P<timestamp>[\d\.]+),' ,
5554
5655 # Changes randomly between RCC sessions.
57- br'[0-9a-f]+,'
56+ br'[0-9a-f]+,' ,
5857
5958 # RCC's own log level.
60- br'(?P<rcc_log_num>\d+)'
59+ br'(?P<rcc_log_num>\d+)' ,
6160
6261 # Gets FLog type.
63- br' \[(?P<log_name>.*?)\]'
62+ br' \[(?P<log_name>.*?)\]' ,
6463
6564 # Captures the rest of the line.
66- br' (?P<rest_of_line>.+)$'
67- ),
68-
69- # 2018M
70- (
71- br'^'
65+ br' (?P<rest_of_line>.+)$' ,
66+ ])),
67+ re .compile (b'' .join ([
68+ # 2018M
69+ br'^' ,
7270
7371 # Current timestamp.
74- br'(?P<timestamp>[\d\.]+),'
72+ br'(?P<timestamp>[\d\.]+),' ,
7573
7674 # Changes randomly.
77- br'[0-9a-f]+,'
75+ br'[0-9a-f]+,' ,
7876
7977 # RCC's own log level.
80- br'(?P<rcc_log_num>\d+)'
78+ br'(?P<rcc_log_num>\d+)' ,
8179
8280 # Captures the rest of the line.
83- br' (?P<rest_of_line>.+)$'
84- ),
85-
86- # 2018M
87- (
88- br'^'
81+ br' (?P<rest_of_line>.+)$' ,
82+ ])),
83+ re .compile (b'' .join ([
84+ # 2018M
85+ br'^' ,
8986
9087 # Current timestamp.
91- br'(?P<timestamp>[\d\.]+),'
88+ br'(?P<timestamp>[\d\.]+),' ,
9289
9390 # Changes randomly.
94- br'[0-9a-f]+,'
91+ br'[0-9a-f]+,' ,
9592
9693 # RCC's own log level.
97- br'(?P<rcc_log_num>\d+),'
94+ br'(?P<rcc_log_num>\d+),' ,
9895
9996 # Constant across all RCC logs.
100- br'GameServer,'
97+ br'GameServer,' ,
10198
10299 # Defaults to 1818.
103- br'[^\s,]+,'
100+ br'[^\s,]+,' ,
104101
105102 # Defaults to 13058.
106- br'[^\s,]+,'
103+ br'[^\s,]+,' ,
107104
108105 # Defaults to "https://localhost:2005/.127.0.0.1".
109- br'[^\s,]+,'
106+ br'[^\s,]+,' ,
110107
111108 # Constant across all RCC logs.
112- br'Test,'
109+ br'Test,' ,
113110
114111 # Defaults to "https://localhost:2005".
115- br'[^\s,]+,'
112+ br'[^\s,]+,' ,
116113
117114 # Constant across all RCC logs.
118- br'unknown,'
115+ br'unknown,' ,
119116
120117 # Constant across all RCC logs.
121- br'Test'
118+ br'Test' ,
122119
123120 # Captures the rest of the line.
124- br' (?P<rest_of_line>.+)$'
125- ),
121+ br' (?P<rest_of_line>.+)$' ,
122+ ]) ),
126123]
127124
128125
@@ -139,9 +136,9 @@ def get_message(log_filter: filter.filter_type_bin, bcolors: bc.bcolors, text: b
139136
140137 match = next (
141138 (
142- re .match (pattern , text )
139+ pattern .match (text )
143140 for pattern in patterns
144- if (match := re .match (pattern , text )) is not None
141+ if (match := pattern .match (text )) is not None
145142 ), None ,
146143 )
147144
0 commit comments