-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprocessor_regex.py
More file actions
19 lines (17 loc) · 800 Bytes
/
processor_regex.py
File metadata and controls
19 lines (17 loc) · 800 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import re
def classify_with_regex(log_msg):
patterns = {
r'Backup completed successfully.' : 'System Notification',
r'Backup started at \d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}.' : 'System Notification',
r'Disk cleanup completed successfully.' : 'System Notification',
r'Backup ended at \d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}.' : 'System Notification',
r'\d{4}-\d{2}-\d{2}( \d{2}:\d{2}:\d{2})?' : 'System Notification',
}
for pattern, label in patterns.items():
if re.search(pattern, log_msg):
return label
elif 'email' in log_msg.lower():
return 'Email Service'
elif 'user' in log_msg.lower():
return 'User Activity'
return None