Spaces:
Sleeping
Sleeping
Commit
·
7f0bab5
1
Parent(s):
b3b9963
Add separator usage
Browse files- utils/log2pandas.py +5 -1
utils/log2pandas.py
CHANGED
|
@@ -13,12 +13,16 @@ class LogParser:
|
|
| 13 |
def __init__(self, file_path, log_type):
|
| 14 |
self.file_path = file_path
|
| 15 |
self.log_definition = log_definitions[log_type]
|
|
|
|
| 16 |
|
| 17 |
def parse_line(self, line):
|
| 18 |
"""Parse a line from the log file using the provided definition."""
|
| 19 |
# Start by replacing [ and ] with spaces
|
| 20 |
line = line.replace("[", " ").replace("]", " ")
|
| 21 |
-
|
|
|
|
|
|
|
|
|
|
| 22 |
# Ignore the line if it does not contain enough tokens
|
| 23 |
if len(tokens) < len(self.log_definition["fields"]):
|
| 24 |
return None
|
|
|
|
| 13 |
def __init__(self, file_path, log_type):
|
| 14 |
self.file_path = file_path
|
| 15 |
self.log_definition = log_definitions[log_type]
|
| 16 |
+
self.log_separator = self.log_definition["sep"]
|
| 17 |
|
| 18 |
def parse_line(self, line):
|
| 19 |
"""Parse a line from the log file using the provided definition."""
|
| 20 |
# Start by replacing [ and ] with spaces
|
| 21 |
line = line.replace("[", " ").replace("]", " ")
|
| 22 |
+
|
| 23 |
+
# Get separator from log definition, default to whitespace if not specified
|
| 24 |
+
tokens = line.strip().split(self.log_separator)
|
| 25 |
+
|
| 26 |
# Ignore the line if it does not contain enough tokens
|
| 27 |
if len(tokens) < len(self.log_definition["fields"]):
|
| 28 |
return None
|